Ok, I sort of touched on this question in another thread, but not really. This code is a simple cart that displays the available options, pulled from the database. When clicked the items in the cart are displayed on the left. What I want to do is when an item on the right is selected and displayed on the left, it should then not show on the right.
For that right side I think I need to do a query where the oxygen_serial is not (<>) what is in the cart...but I have no idea how to go about doing this. I'll need to loop through the array so the query will search for every item in the cart, but I can not figure out how to go about this with the way the loops in the code are already setup.
If I do something like this:
foreach($cart as $serial => $qty){
$query = "SELECT * FROM hmedical_oxygen WHERE oxygen_status=1 AND oxygen_serial <> $serial");
}
No matter where I place it...if I place the while within the foreach it's going to run the query for each.
Anyway, not sure if I'm making sense, but I really want to figure this out and I have no idea how to go about doing it. ANY help would be greatly appreciated.
<?
session_start();
if($new){
if(!session_is_registered("cart")){
$cart = array();
session_register("cart");
}
$cart[$new] = 1;
}
?>
<table border=1 width=90%>
<tr>
<td valign=top width=50%>
Selected Tanks
<?
foreach($_GET as $serial => $qty) {
if ($qty == 0){
unset($cart[$serial]);
}
}
if($cart&&array_count_values($cart)){
echo("<table border=1 bordercolor=000000><tr><td>serial</td><td>lot</td><td>tank type</td></tr>");
foreach($cart as $serial => $qty){
$url = "testbed2.php?$serial=0";
mysql_connect ('host', 'login', 'pwd');
mysql_select_db ('db');
$query = "SELECT * FROM hmedical_oxygen WHERE oxygen_status=1 AND oxygen_serial = $serial";
$result = mysql_query("$query");
while ($row = mysql_fetch_array($result)){
echo("<tr><td><a href=$url>$row[oxygen_serial]</a></td><td>$row[oxygen_lot]</td><td>$row[oxygen_tank] - $qty</td></tr>");
}
}
echo("</table>");
}
else{
echo("<BR>No Tanks Selected");
}
?>
</td>
<td valign=top>
Tank Options
<?
echo("<table border=1 bordercolor=000000><tr><td>serial</td><td>lot</td><td>tank type</td></tr>");
mysql_connect ('host', 'login', 'pwd');
mysql_select_db ('db');
$query = "SELECT * FROM hmedical_oxygen WHERE oxygen_status=1";
$result = mysql_query("$query");
while ($row = mysql_fetch_array($result)){
$url = "testbed2.php?new=".($row["oxygen_serial"]);
echo("<tr><td><A href=$url>$row[oxygen_serial]</a></td><td>$row[oxygen_lot]</td><td>$row[oxygen_tank] $serial</td></tr>");
}
echo("</table>");
?>
</td>
</tr>
</table>