The Solution is as follows:
<?php
$sess = session_id();
session_register();
require('conn.php');
$display = "";
$get_cart = "select * from ordertr where session_id = '$sess' ";
$get_cart_res = mysql_query($get_cart) or die(mysql_error());
$i=1;
$count=mysql_num_rows($get_cart_res);
if(mysql_num_rows($get_cart_res) <1)
{
$display .= "<b> You have no items in your cart <a href = \"book.php?sender=1\">
Go To Store </a> </b>";
}
else
{
$display .=
"
<form method = \"post\" action = \"showcart.php\" name = \"myform\">
<table cellspacing = 0 cellpadding = 0 align = \"center\"
style=\"BORDER-RIGHT: #EFD76B 1px solid; BORDER-TOP: #EFD76B 1px solid; BORDER-LEFT:
#EFD76B 1px solid; BORDER-BOTTOM: #EFD76B 1px solid\" width = 510 >
<tr valign = \"top\">
<td width = 100 valign = \"top\" bgcolor = \"white\" align = \"center\"><font size = 2 color = \"#5581D2\"> <b>Book</b></font> </td>
<td width = 100 valign = \"top\" bgcolor = \"white\" align = \"center\"> <font size = 2 color = \"#5581D2\"><b>Price</b></font> </td>
<td width = 100 valign = \"top\" bgcolor = \"white\" align = \"center\"> <font size = 2 color = \"#5581D2\"><b>Quantity</b></font> </td>
<td width = 10 valign = \"top\" bgcolor = \"white\" align = \"center\">
</td>
<td width = 100 valign = \"top\" bgcolor = \"white\" align = \"center\"> <font size = 2 color = \"#5581D2\"><b>Total</b></font> </td>
<td width = 100 valign = \"top\" bgcolor = \"white\" align = \"center\"> <font size = 2 color = \"#5581D2\"><b>Action </b></font></td>
</tr>" ;
$colorRow = 1;
while ($cart = mysql_fetch_array($get_cart_res))
{
$rowStyle = ($colorRow % 2 == 1) ? "#0059FF" : "#008AFF";
$id = $cart['id'];
$item_title = stripslashes($cart['item']);
$item_price = $cart['price'];
$item_qty = $cart['qty'];
$total_price = sprintf("%.02f", $item_price*$item_qty);
$display .= "
<tr
style=\"background-color:$rowStyle\">
<td align = \"center\"> $item_title </td>
<td align = \"center\"> $item_price </td>
<td align = \"center\"> <input type = \"text\" name = \"itemqty[]\" value = \"$item_qty\" size = 2> </td>
<td><input type = \"hidden\" name = \"id[]\" value = \"$id\" class = \"filecheck\" ></td>
<td align = \"center\"> \$$total_price </td>
<td align = \"center\"> <a href =\"removefromcart.php?id=$id\"> Remove </td>
</tr>";
$colorRow++;
}
$display .= "
<tr><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
<tr>
<td align = \"center\" colspan = 6><input type = \"hidden\" name = \"hidedel\" value = 1>
<input type=\"button\" value=\"Check Out\" class=\"buttontext\"
onClick=\"document.location.href='checkout.php'\">
<input type = \"reset\" class=\"buttontext\" class=\"buttontext\">
<input type = \"submit\" value = \"update\" class=\"buttontext\">
<input type = \"button\" value = \"Continue Shopping\"
onClick=\"document.location.href='book.php?sender=1'\" class=\"buttontext\" style = \"width:100pxs;\">
</td>
</tr>
<tr><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
</table></form>";
}
?>
<?php echo "$display" ; ?>
<?php
if(isset($_POST['hidedel']))
$javer =
"
<script type=text/javascript>
setTimeout('document.location=document.location' ,200);
</script>
" ;
{
for ($i = 0; $i < count($POST['id']); $i++)
{
$updateSQL =
sprintf("UPDATE ordertr SET
qty ='".$POST['itemqty'][$i]."'
WHERE id='".$_POST['id'][$i]."' ");
$Result1 = mysql_query($updateSQL) or die(mysql_error());
echo "$javer" ;
}
}
?>
Thanks
Peter
webdeveloper_5@yahoo.com
peterman wrote:Hello
I have a wish list like a shoping caty based on a mysql databse where i retrieve records with php
I need to update the quantity which is in a text fields
input type = text name = quantity[] value = $quantity
input type = checkbor value = $id name = id[]
I need to update quantities based on the primary id represented with id with a single submit
Can you help me please
thanks
webdeveloper_5@yahoo.com