//$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

Member Avatar for diafol

what's MULITY?

they only update the last row

they update only the last record

Member Avatar for diafol

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.

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)

Member Avatar for diafol

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.

<?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\">";

}}

?>
Member Avatar for diafol

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.

$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

Member Avatar for diafol

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>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.