0

//$update = $_POST;
//$quantity = $_POST;
//if($update){
//for($a=0;$a<$count;$a++){
mysql_query ("UPDATE productorder SET Product_quantity = '$quantity' WHERE id = '$id'");

THEY ONLY UPDATE THE LAST RECORD HOW I UPDATE THE MULITY RECORDS

2
Contributors
10
Replies
11
Views
6 Years
Discussion Span
Last Post by diafol
0

Sorry I still don't understand what you mean by 'mulity' - I Googled it and couldn't find it.

//$update = $_POST['update'];
//$quantity = $_POST['quantity'];
//if($update){
//for($a=0;$a<$count;$a++){
mysql_query ("UPDATE productorder SET Product_quantity = '$quantity' WHERE id = '$id'");

This doesn't do anything does it? Your loop is commented out and your $id seems to be static. Odd.

0

i have 3 row(records) in database table like
id order quantity
1 2232 1
2 2232 1
3 2232 1
they pick the last row(records)
id order quantity
3 2232 1
and update
how i update the i and 2 rows(records)

0

show your complete code -it's impossible to see what you're doing from the bit you included. You don't include a loop so I assume it is impossible to update all unique 'id' records otherwise.

0
<?php        
// ********** update ************ 
mysql_connect("$hostname_boss", "$username_boss", "$password_boss")or die("cannot connect");
mysql_select_db("$database_boss")or die("cannot select DB");
$sql="SELECT * FROM productorder";
$result=mysql_query($sql);
                            $count=mysql_num_rows($result);                 

$update = $_POST['update'];
$quantity = $_POST['quantity'];
$id = $_POST['id'];
if($update){
for($a=0;$a<$count;$a++){
$insert="UPDATE productorder SET Product_quantity = '$quantity' WHERE id = '$id'";  
$result1 = mysql_query($insert);
echo "<meta http-equiv=\"refresh\" content=\"0;URL=shoping_cart12.php\">";

}}

?>

Edited by Reverend Jim: Fixed formatting

0

first of all, you've included a meta refresh inside the loop. Don't do this. I'd use header() after the loop.

You're tables confuse me. I don't understand why you want to get the count of your orders and then loop over your insert statement that number of times.

UPDATE productorder SET Product_quantity = '$quantity' WHERE id = '$id'

This will only ever update one record as it is unique (I assume the id is a primary key).


I'm thinking that you've misunderstood what you're trying to do.

0

$update = $_POST;
$quantity = $_POST;
$id = $_POST;

$insert1="UPDATE productorder SET Product_quantity = '$quantity' where product_id = '$id'";
$result1= mysql_query($insert1);
// if successful redirect to delete_multiple.php
if($result1){
echo "<meta http-equiv=\"refresh\" content=\"0;URL=shoping_cart.php\">";
}
mysql_close();

no dear they only pick the last record and update it
2 problem they continuously refresh the page
how i can i time refresh the page

0

Sorry, I don't understand. Your code above should work. If you want to 'time refresh the page', do you mean pause for a while then refresh? If so:

<?php
header('Refresh: 5; URL=http://www.example.com');
?>
<p>You will be redirected in 5 seconds...</p>

Edited by diafol: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.