Updating Multiple Rows in MySQL using PHP

There are so many tutorials on how to update one (1) record at a time. But only few tutorial on how to update multiple rows at once.

I dedicate this tutorial to my 3rd year students.

Save the following code as select.php:

‘;
echo ‘

‘;
echo ‘

ID

‘;
echo ‘

Name

‘;
echo ‘

Address

‘;
echo ‘

‘;

echo “

\n”;
while ($students = mysql_fetch_array($result)) {
echo ‘

‘;
echo “

{$students[‘id’]}

“;
echo “

{$students[‘name’]}

“;
echo “

“;
echo ‘

‘;
++$i;
}
echo ‘

‘;
echo “

“;
echo ‘

‘;
echo “

“;
echo ‘

‘;
?>
Save the following code as update.php:

Updated!

“;
++$i;
}
?>
Import the SQL Statement into your database called “students” using PHPMyAdmin included in the zip file.



(Visited 13 times, 1 visits today)
Add, Edit and Delete Record using PHP/MySQL
Contact Module for Drupal

Comments

comments

Leave a Reply

Your email address will not be published. Required fields are marked *