Re: Urgent Need, Update Multiple MySql Records with a single form click

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is the Solution:
<?php
$display = "" ;
$get_cart = "select * from table1  where session_id = '$sess' ";

$get_cart_res = mysql_query($get_cart) or die(mysql_error());
$i=1;

$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>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&
nbsp;</td><td>&nbsp;</td></tr>
<tr>
<td><input type = \"hidden\" name = \"hidedel\" value = 1></td>
<td align = \"center\" colspan = 3>
<input type=\"button\"  value=\"Check Out\"  class=\"buttontext\" 
onClick=\"document.location.href='checkout.php'\">
<input type = \"reset\" class=\"buttontext\">


</td><td><input type = \"submit\" value = \"update\"></td>

<td>
<input type = \"button\" name = \"Continue Shopping\" 
onClick=\"document.location.href='book.php?sender=1'\" >

</td>

</tr>
<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&
nbsp;</td><td>&nbsp;</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 table1 SET 
qty ='".$_POST['itemqty'][$i]."' 
 WHERE id='".$_POST['id'][$i]."' "); 

  $Result1 = mysql_query($updateSQL) or die(mysql_error()); 
  echo "$javer" ;
} 


}
?>


--- In php-objects@xxxxxxxxxxxxxxx, "webdeveloper_5" 
<webdeveloper_5@...> wrote:
>
> Hello,
> I have an urgent issue, I have a form retrieved from a mysql 
database, 
> I need to update quantity which is displayed in a text input by a 
> single submit based on primary id displayed as checkboxes, records 
are 
> retrieved from database based on their session id, I have placed 
both 
> the checkbos as name = id[] and quantity as name = quantity[]tp 
provide 
> an array, 
> 
> I will send the code sample tomorrow as demonstration
> 
> Many Thanks
> webdeveloper_5@...
>








------------------------ Yahoo! Groups Sponsor --------------------~--> 
Protect your PC from spy ware with award winning anti spy technology. It's free.
http://us.click.yahoo.com/97bhrC/LGxNAA/yQLSAA/saFolB/TM
--------------------------------------------------------------------~-> 

PHP Data object relational mapping generator
http://www.metastorage.net/ 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/php-objects/

<*> To unsubscribe from this group, send an email to:
    php-objects-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Soap]     [Kernel Newbies]     [Yosemite]     [Yosemite Campsites]

  Powered by Linux