<?php $result = mysql_db_query($db, "SELECT * FROM gg_cart where billingemail = '".$_SESSION['aff_valid_account']."'"); while ($record = mysql_fetch_array($result)) //i did below to see my result, how do I use above to make below work if there are multiple results? $myresult = "$record[billingitem]"; print "$myresult"; { $result = mysql_db_query($db, "SELECT name, description, cat, now FROM gg_products where id = '$myresult'"); while ($qry = mysql_fetch_array($result)) { echo "<font face=arial><TABLE width=800 border=1 cellspacing=0 cellpadding=3>"; echo "<tr><th>Item Name</th><th>Item Description</th>"; echo "<th>Platform</th><th>price</th><th>Action</th></tr>"; print "<tr>"; print "<td><font size=2>"; print "$qry[name]"; print "</td>"; print "<td><font size=2>"; print "$qry[description]"; print "</td>"; print "<td><font size=2>"; print "$qry[cat]"; print "</td>"; print "<TD><font size=2>"; print "$qry[now]"; print "</td>"; print "<TD><font size=2>"; print "delete"; print "</td>"; print "</tr>"; } print "</TABLE>"; } ?> PHP: please, any help
sorry, thought you would notice the line explaining the problem. I need to get the billing items from one table for a user, and then display the product details with data from another table. belo only gives me one result, where there should me more $result = mysql_db_query($db, "SELECT * FROM gg_cart where billingemail = '".$_SESSION['aff_valid_account']."'"); while ($record = mysql_fetch_array($result)) $q= $record[billingitem]; print "$q"; { $result = mysql_db_query($db, "SELECT * FROM gg_products where id = '$q'"); while ($qry = mysql_fetch_array($result)) { PHP:
try to put single qoute on the line $q= $record[billingitem]; this must be $q= $record['billingitem'];
You need to place your second while loop into the first one .. It will go through all items from order and at the same time will fetch this item info from products table !
Thanx, but I think I'm just too much of noob. <?php $result = mysql_db_query($db, "SELECT * FROM gg_cart where billingemail = '".$_SESSION['aff_valid_account']."'"); while ($record = mysql_fetch_array($result)) $q= $record[billingitem]; { $result = mysql_db_query($db, "SELECT * FROM gg_products where id = '$q'"); while ($qry = mysql_fetch_array($result)) { echo "<font face=arial><table width=800 border=1 cellspacing=0 cellpadding=3>"; echo "<tr><th>Item Name</th><th>Item Description</th>"; echo "<th>Platform</th><th>Price</th><th>Action</th></tr>"; print "<tr>"; print "<td><font size=2>"; print "$qry[name]"; print "</td>"; print "<td><font size=2>"; print "$qry[description]"; print "</td>"; print "<td><font size=2>"; print "$qry[cat]"; print "</td>"; print "<td><font size=2>"; print $cur; print "$qry[now]"; print "</td>"; print "<td><font size=2>"; ?> <a href="?q=deletecart?id=<?php echo $q ; ?>">Delete</a> <?php print "</td>"; print "</tr>"; print "<tr><td>"; print "</table>"; print "</br>"; } } ?> PHP:
$q before while loop starts .. needs to be inside it as your using fetch function. - this could be a reason why you've only 1 value <?php $result = mysql_db_query($db, "SELECT * FROM gg_cart where billingemail = '".$_SESSION['aff_valid_account']."'"); while ($record = mysql_fetch_array($result)) { $q= $record[billingitem]; $result = mysql_db_query($db, "SELECT * FROM gg_products where id = '$q'"); while ($qry = mysql_fetch_array($result)) { echo "<font face=arial><table width=800 border=1 cellspacing=0 cellpadding=3>"; echo "<tr><th>Item Name</th><th>Item Description</th>"; echo "<th>Platform</th><th>Price</th><th>Action</th></tr>"; print "<tr>"; print "<td><font size=2>"; print "$qry[name]"; print "</td>"; print "<td><font size=2>"; print "$qry[description]"; print "</td>"; print "<td><font size=2>"; print "$qry[cat]"; print "</td>"; print "<td><font size=2>"; print $cur; print "$qry[now]"; print "</td>"; print "<td><font size=2>"; ?> <a href="?q=deletecart?id=<?php echo $q ; ?>">Delete</a> <?php print "</td>"; print "</tr>"; print "<tr><td>"; print "</table>"; print "</br>"; } } ?> PHP: Another thing .. echo main table elements before all while loops, so it will not create a new table, but only new rows
I'm still not getting it right, I'm trying to build a shopping cart around my existing site here Everything is basically done, if I can just get this to work. any help anyone???