update multirows

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Okay. Last time I try this. You skipped the most critical part:
You would then loop over $_POST['foo'] where the keys will be the original room number and the value will be an array of the numberRoom and stateRoom values. Each iteration over foo will require a new UPDATE query.
hrubos
Forum Contributor
Posts: 172
Joined: Sat Oct 07, 2006 3:44 pm

Post by hrubos »

Thank you very much for your try

I have done this
page2.php

Code: Select all

print_r($_POST['foo']);

foreach ($_POST['foo'] as $key => $value) {

  list($new_number_room, $new_state_room) = $value;

  $query = "UPDATE room p SET p.number_room = '$new_number_room',

p.state_room = '$new_state_room' WHERE p.id_numberRoom = $key"; 
mysql_query($query) or die(mysql_error());
}
Did you think that?
Post Reply