View Single Post
  #2 (permalink)  
Old 11-08-03, 04:03 PM
wheezy360's Avatar
wheezy360 wheezy360 is offline
Newbie Coder
 
Join Date: Nov 2003
Location: Toronto, ON
Posts: 64
Thanks: 0
Thanked 0 Times in 0 Posts
I'm not sure about the scope of your project here but it might be more beneficial to store the manufacturer's info in one table, and the products in another table and give the product table a field called mfg_id which is a foreign key to the manufacturer's table.. From then you could have two queries:

PHP Code:

<?

/* include your db connection crap */

$sql "SELECT * FROM manufacturers";
$mfg_result = @mysql_query($sql$connection) or die("Couldn't execute query: " .mysql_error());
while(
$mfg mysql_fetch_array($mfg_result)){
   echo 
$mfg['name'];
   
$sql "SELECT * FROM products WHERE mfg_id=\"" $mfg['id'] . "\"";
   
$product_result = @mysql_query($sql$connection) or die("Couldn't execute query: " mysql_error());
   while(
$product mysql_fetch_array($product_result)){
      echo 
$product['name'];
   }
}
?>
?>
Reply With Quote