A
Anonymous
Guest
Anyone knows where i could find an example of a PHP shopping cart using sessions instead of having queries whenever a request(add, edit, delete) on cart is made.
I'm making one but i'm currently having problems.
here's my code. I wish to be able to list the order in a table and show quantity. I plan to put a textfield wherein they could change the quantity and update. upon update $price_ar should be able to change.
Suggestions pls......
I'm making one but i'm currently having problems.
here's my code. I wish to be able to list the order in a table and show quantity. I plan to put a textfield wherein they could change the quantity and update. upon update $price_ar should be able to change.
Suggestions pls......
Code:
<?
session_start();
require("cn.php");
session_register("item_id");
session_register("order_qty");
$order_qty = $_POST['order_qty'];
session_register('order_qty');
$item_id = $_POST['item_id'];
$select = "select * from item where item_id like '".$item_id."%' order by item_id ASC";
$rs = mysql_query($select) or die(mysql_error());
$count = mysql_num_rows($rs);
echo $count." results found!<br><br>";
if($count==1){
$rows = mysql_fetch_array($rs); //kunin as array results
$item_id = $rows["item_id"];
$description = $rows["description"];
$s_price = $rows["price"];
$price = $order_qty * $rows["price"];
$qty = $rows["qty"];
if(!isset($_SESSION["order"])){
$order = array( 'item:' => $item_id, 'description:' => $description, 'price:' => $price);
session_register('order');
}else{
array_push($order,$item_id,$description,$price);
}
if(!isset($_SESSION["item"])){
$item = array($item_id);//lagay sa array values
$desc = array($description);
$price_ar= array($price);
print_r($test);
session_register('item');
session_register('desc');
session_register('price_ar');
} else {
array_push($item, $item_id); :help: :help:
array_push($desc, $description);
array_push($price_ar, $price);
session_register('item');
session_register('desc');
session_register('price_ar');
}
}
?>
<table border="1">
<tr>
<? while (list($key,$value) = each($order)) {
echo "<td> $key : $value </td></tr><tr>";
}?>
</tr>
</table>