Jump to content

Query with while loop


thefollower

Recommended Posts

I have a query with a while loop but just prior the the while loop i want to check if no rows are found, and if there isn't any rows found then it will load up a different while loop.... but not sure how to do the check to find if theres any rows...

This is what i have:

 

$GetCommercial = mysql_query("SELECT * FROM businesses WHERE Catergory = 'Commercial' AND CityID = '1' AND BusinessType='Food Market'")
or die(mysql_error());
Echo'<div id="bv_" style="position:absolute;left:357px;top:300px;width:150px;height:16px;z-index:3" align="center">
<font style="font-size:13px" color="#FFFFFF" face="Arial"><b><u>Food Markets</u></b></font></div>
<div id="bv_" style="position:absolute;left:221px;top:341px;width:150px;height:16px;z-index:2" align="center">';
while($GetCommercialResult = mysql_fetch_array($GetCommercial)) {
Echo'<font style="font-size:13px" color="#FFFFFF" face="Arial"><b><u></br></br></br>';
Echo $GetCommercialResult['BusinessName'];
Echo'</u></b></font>';
}
Echo '</div>';

Link to comment
Share on other sites

Assuming all manner of thinsg - but I have in the past encountered installations where teh number of rows being 0 it has been evaluated as FALSE and spitting out an error.  These I guess were the little idiosyncrasies of the installations - with a query that was perfectly well formed I might add.

Link to comment
Share on other sites

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.