Jump to content

Recommended Posts

while($row10000=mysql_fetch_array($result10000)){
$product_id3=$row10000['product_id'];
$sql15000="SELECT * FROM $tbl_name WHERE product_id=".$product_id3;
$result15000=mysql_query($sql15000);
while($row15000=mysql_fetch_array($result15000)){
extract($row15000);
if(mysql_num_rows($result15000)==0){
$content='<div class="center">Search found no results.</div>';
}
else{
$content.=$product_name;
}
}
}

 

The above does not display the $content variable when there are no rows returned, just comes up with a blank page. Works fine when there are results returned.

 

Link to comment
https://forums.phpfreaks.com/topic/236585-mysql_num_rows-not-working/
Share on other sites

That is how it should work, as the while statement will never run, being that it will return false on row 0.

 

You MUST put the mysql_num_rows() function BEFORE the while statement.

 

That's what I figured... was just to lazy to change it to try it myself.

 

 

EDIT: Just tried it, still a blank page.

while($row10000=mysql_fetch_array($result10000)){
$product_id3=$row10000['product_id'];
$sql15000="SELECT * FROM $tbl_name WHERE product_id=".$product_id3;
$result15000=mysql_query($sql15000);
if(mysql_num_rows($result15000)==0){
$content='<div class="center">Search found no results.</div>';
}
else{
while($row15000=mysql_fetch_array($result15000)){
extract($row15000);
$content.=$product_name;
}
}
}

Well turned on error reporting and all I'm getting is notices that I have an Undefined Index and that the Content variable is undefined (because it's being called but nothing's a signed to it, for whatever reason.

 

 

The page is actually displayed properly when the keyword exists, just when there are no results returned does it not show anything.

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.