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");


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to