Jump to content

Count and Display query


Go to solution Solved by SkyRanger,

Recommended Posts

Is it possible to count query rows and display query, tried a number of things but can't get row count:

$rowhsr = $wpdb->get_results( "SELECT * FROM locations where stname like '%" . $houseaddy ."%'");
       
       $hauntcount = $rowhsr->num_rows;
       echo 'Number of entries found:' . $hauntcount;
      
       foreach ( $rowhsr as $rowhsr )

         { echo $rowhsr->stname } 
Link to comment
https://forums.phpfreaks.com/topic/297353-count-and-display-query/
Share on other sites

No. You got a better result. This time you show a string that apparently contains 17 printable chars, as the var_dump told you. As Barand pointed out, your previous test showed only 10 printable (visible) chars, yet var_dump said there were 17 actual chars in the content.

 

So - why are you getting non-printable chars in your input?

ok, got a new error:

Notice: Trying to get property of non-object in \www\wp-content\plugins\addysearch\index.php on line 101
string(12) "815 pembroke" We found 0 results.

Line 100: $rowhsr = $wpdb->get_results( "SELECT * FROM locations where stname like '%" . $houseaddy ."%'");

Line 101: $hauntcount = $rowhsr->num_rows;


Line 102:  var_dump($houseaddy);

And is it WHAT YOU EXPECT TO SEE? Might be nice to let us know what you are getting if you want us to continue to help you.

 

Show us your current code and what you are getting for output please. Please read this last twice so that you can be sure to give me the help I am asking for.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.