Jump to content

Count and Display query


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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.