khaja.jab
06-13-2012, 08:23 AM
i want update multiple rows with different text.
My table structure:
+----+---------+
| id | content |
+----+---------+
| 2 | abc |
+----+---------+
| 14 | def |
+----+---------+
I have a code. but it was updating that particular id only.
i want to update multiple ids.
Below is my code: can any one provide the full code please...
<?php
$hostname = "localhost";
$username = "";
$password = "";
$database = "";
// Connect to the database
mysql_connect($hostname, $username, $password) OR DIE("Unable to connect");
mysql_select_db("$database") or die("Unable to select database");
if (isset($_POST['ud_date'])) {
$query = sprintf("UPDATE test_mysql SET content='%s' WHERE id=%d",
mysql_real_escape_string($_POST['ud_date']),
2);
if (mysql_query($query)) {
echo 'update query succeeded';
} else {
else echo 'update query failed';
}
} else {
echo 'please submit the form';
}
please give the exact code.
My table structure:
+----+---------+
| id | content |
+----+---------+
| 2 | abc |
+----+---------+
| 14 | def |
+----+---------+
I have a code. but it was updating that particular id only.
i want to update multiple ids.
Below is my code: can any one provide the full code please...
<?php
$hostname = "localhost";
$username = "";
$password = "";
$database = "";
// Connect to the database
mysql_connect($hostname, $username, $password) OR DIE("Unable to connect");
mysql_select_db("$database") or die("Unable to select database");
if (isset($_POST['ud_date'])) {
$query = sprintf("UPDATE test_mysql SET content='%s' WHERE id=%d",
mysql_real_escape_string($_POST['ud_date']),
2);
if (mysql_query($query)) {
echo 'update query succeeded';
} else {
else echo 'update query failed';
}
} else {
echo 'please submit the form';
}
please give the exact code.