Hello guys I need help with the following code.
I am building a Customer Management System. What I am trying here is to update multi rows for ORDERS table => Multi rows with one click submit. Before this page I have another page i have inputs in my form:
<input type="text" name="qty[]" value="<?php echo $row["qty"]; ?>" />
<input type="text" name="desc[]" value="<?php echo $row["desc"]; ?>" />
<input type="text" name="price[]"value="<?php echo $row["price"]; ?>" />
When submitted the form it will go to next page that follow:
<?php
if(isset($_POST["submit"])){
$qty = $_POST['qty'];
$desc = $_POST['desc'];
$price = $_POST['price'];
$order = $_POST['order'];
$customer = $_POST['customer'];
$i = 0;
$count = count($qty);
for($i=0; $i < $count; $i++){
$qty = $qty[$i];
$desc = $desc[$i];
$price = $price[$i];
$update = mysql_query("UPDATE `orders` SET `qty` = '".$qty."', `desc` = '".$desc."', `price` = '".$price."' WHERE `order_id` = '".$order."' ");
}
?>
This code looks likes update sometimes and not, also I am getting this error for this code when I Update multi rows.
Notice: Uninitialized string offset: 1 in
Please help guys to solve this one.
Thanks From Eddy
?qty[0]=1 OR 1=1; SELECT * FROM users; --$_POST['qty'],$_POST['desc']or$_POST['price']is string, rather than array.