Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9229321
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:32:33+00:00 2026-06-18T05:32:33+00:00

I’m trying to show this when there is questions to answer questions and this

  • 0

I’m trying to show this when there is questions to answer questions

and this when there is no questions to answer. no questions

This is a code I have tried using, the commented out lines are the if loop I tried but it always returned 1

<?php
        $dbtype = "mysql";
        $dbhost = "localhost";
        $dbname = "starsqa";
        $dbuser = "root";
        try {
            $pdo_conn = new PDO("mysql:host=$dbhost;dbname=$dbname", $dbuser);
        } catch (PDOException $ex) {
            echo $ex->getMessage();
        }

        $qry_string = "select * from questions inner join stars on stars.starID = questions.starID where stars.starID = ? && approved = 1 && answered = 1 && `check` = 0";
        $prep = $pdo_conn->prepare($qry_string);
        $starid = $_SESSION['starid'];
        $prep->execute(array($starid));
        //if (count($qry_string) > 0) {
            //echo count($qry_string);
            echo "<table style='border:0px; background-color:#8C7E6C;'><thead style='border:0px;'><tr style='border:0px solid white; background-color:#153E7E; color:white; padding: 5; margin: 5;'><th style='border:1px white; padding: 5; margin: 5;'>Question</th><th style='border:1px white; padding: 5; margin: 5;'>Response</th></tr></thead><tbody>";
            while ($row = $prep->fetch(PDO::FETCH_ASSOC)) {
                echo "<tr style='border:1px white; background-color:lightblue; padding: 5; margin: 5;'><td style='border:1px white; padding: 5; margin: 5;'>{$row['question']}</td>
                      <td style='border:1px white; padding: 5; margin: 5;'><textarea rows='4' cols='50' id='{$row['questionID']}' class='response'>{$row['response']}</textarea></td></tr>";
            }
            echo "</tbody></table>";     
            echo "<br><button type='button' class='save_btn'>Save All</button><br><br>";
        //}
//        if (count($qry_string) < 1) {  
//          echo count($qry_string); 
//          echo "no question to answer atm"; 
//        }
        ?>   

anyone got ideas on why this isn’t working or another way to achieve this?

it’s working now (thanks showdev) using this:

$prep->execute(array($starid));
//if (count($qry_string) > 0) {
    //echo count($qry_string);
        // $count= count($prep->fetchAll());    
         $count = $prep->rowCount();
         //echo "$count";
         if ($count > 0){
    echo "<table style='border:0px; background-color:#8C7E6C;'><thead style='border:0px;'><tr style='border:0px solid white; background-color:#153E7E; color:white; padding: 5; margin: 5;'><th style='border:1px white; padding: 5; margin: 5;'>Question</th><th style='border:1px white; padding: 5; margin: 5;'>Response</th></tr></thead><tbody>";
    while ($row = $prep->fetch(PDO::FETCH_ASSOC)) {
        echo "<tr style='border:1px white; background-color:lightblue; padding: 5; margin: 5;'><td style='border:1px white; padding: 5; margin: 5;'>{$row['question']}</td>
              <td style='border:1px white; padding: 5; margin: 5;'><textarea rows='4' cols='50' id='{$row['questionID']}' class='response'>{$row['response']}</textarea></td></tr>";
    }
    echo "</tbody></table>";     
    echo "<br><button type='button' class='save_btn'>Save All</button><br><br>";  

}
if ($count < 1) {  
  echo "no question to answer atm"; 
}

just thought of something else it needs once i press save all for ajax to refresh the page and show the new/current information, what function would i use to do this?

i did it 🙂 using this: location.reload();

var html = '';
$(document).ready(function(){
    $(".save_btn").live('click', function() {

        $('.response').each(function(){
            //alert($(this).attr('id'));
            //alert($(this).val());
            if ($(this).val() == '') {
                html = $.ajax({
                    url: "response.php?questionID=" + $(this).attr('id') + "&response=" + $(this).val() + "&check=0",
                    async: false
                }).responseText;
            }   
            if ($(this).val() !== '') {
                html = $.ajax({
                    url: "response.php?questionID=" + $(this).attr('id') + "&response=" + $(this).val() + "&check=1",
                    async: false
                }).responseText;
            }   

        }); 
        alert(html);
        location.reload();
    });
})
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T05:32:34+00:00Added an answer on June 18, 2026 at 5:32 am

    Looks like you are counting your query string rather than the resulting record set. Try fetchAll and count the results or try rowCount:

    $count=count($prep->fetchAll(););
    $count = $prep->rowCount();
    

    From the documentation:

    [rowCount] is not guaranteed for all databases and should not be relied on for portable applications.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know there's a lot of other questions out there that deal with this
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I am trying to loop through a bunch of documents I have to put
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.
I have just tried to save a simple *.rtf file with some websites and
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
This could be a duplicate question, but I have no idea what search terms

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.