Jump to content

Linking Tables Problem


dmschenk

Recommended Posts

I'm having a slight problem with pulling the information from a second table.  I can't seem to get it to recognize that the second table is even there.

 

The prodName field in the prodcat table is what I'm trying to get but it doesn't seem to be working.  Can someone please show me the light?

 

<?php
mysql_select_db($database, $db_srevent);
$query = "SELECT products.*, prodcat.prodName
FROM products, prodcat 
WHERE products.idProdCat = prodcat.idProdCat
ORDER BY products.idProduct";

$products = mysql_query($query, $db_srevent) or die(mysql_error());
$row = mysql_fetch_assoc($products);
$totalRows = mysql_num_rows($products);
?>
/********************/
<?php
$prod = $prod_cat = '';
while (list($idProduct, $idCategoryType, $idProdCat, $prodDescription, $prodSeatCapacity, $prodTentSize, $prodSize, $prodBasePrice, $prodEachPrice, $prodPackof5, $prodName, $dt,) = mysql_fetch_row($products)){
    $dt = ($idCategoryType);
    if ($prod != $idProdCat){
        echo "<br><table border='1' width='900' align='center'><td bgcolor='#E4C6E2'>$idCategoryType / $idProdCat / $prodName</td></tr>\n";
	$prod = $idProdCat;
    }
    if ($prod_cat != $dt){
        echo "<tr><td>$prodDescription / $prodSeatCapacity / $prodTentSize / $prodSize / $prodBasePrice / $prodEachPrice / $prodPackof5</td></tr>\n";
        $prod_cat = $dt;
    }
    else {
        echo "<tr><td>$prodDescription / $prodSeatCapacity / $prodTentSize / $prodSize / $prodBasePrice / $prodEachPrice / $prodPackof5</td></tr>\n";
    }
}
    echo "</table>\n";
?>
<?php mysql_free_result($products); ?>

 

Thanks

Dave

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.