Re: displaying multiple results only one time...

From: Date: Fri, 18 May 2001 15:05:40 +0000
Subject: Re: displaying multiple results only one time...
Groups: php.db 
Request: Send a blank email to php-db+get-9440@lists.php.net to get a copy of this message
Here's my idea: // select all products made by the manufacturer $query="SELECT DISTINCT Name, Prod_ID FROM Product WHERE In_Stock = 1 and Man_ID = '$Man_ID'"; $mysql_result=mysql_query($query, $mysql_link); // loop through the results while($row=mysql_fetch_row($mysql_result)){ // determine whether the product is in the current category $query2="SELECT * FROM Product_Category WHERE Prod_ID = '$row[1]' and Cat_ID = '$Cat_ID'"; $mysql_result2=mysql_query($query2, $mysql_link); // if it is in category, add it to one list if(mysql_num_rows($mysql_result2) != 0){ $ThisCatList .= "$row[0]<br />\n"; } // if it isn't in category, add it to second list else{ $OtherCatList .= "$row[0]<br />\n"; } } // display list from this category print("$ThisCatList"); // display list from other categories print("$OtherCatList");

« previous php.db (#9440) next »