I have a cart which is basically just going to be for presentation on the side of a website, at the moment whenever you click buy on an item it adds the sku to the array of bought items, and then the cart pulls out the description, sku, price, and label for each item with that sku from a database of items. That all works fine, but I want to add a button next to each item that will delete the item on that line if the person chooses not to buy it. Here is my current code:
<?php
include 'connect.php';
mysql_select_db('test', $con);
$arr = array(
"1",
"12",
"123",
"1234",
"1234h",
"12345h",
);
echo "<h1>cart</h1><br />";
echo "bought items: <br />";
echo "<br />";
echo "(Description|(Sku)| - Price <br />";
echo "<br />";
$a_length = count($arr);
for($i=0;$i<$a_length;$i++){
$sku = $arr[$i];
$result = mysql_query("SELECT label,sku,description,price FROM cart_test WHERE sku = '$sku'");
if(!$result){
echo 'could not run query: ' . mysql_error();
exit;
}
$row = mysql_fetch_row($result);
echo "$row[0]: $row[2]($row[1]) - $$row[3]";
echo "<br />";
}
?>
Did you try removing it from the array? You’re not inserting anything into the database, so it doesn’t care.