Problem to update table in mysql using php

Below is my code from this code i am able to update only that particular row now i want to update some bunch of rows with different content so please edit this code sir This is my table structure: +----+---------+ | id | content | +----+---------+ | 2 | abc | can any one help me please +----+---------+ | 14 | def | +----+---------+
  1. <?php
  2. $hostname = "localhost";
  3. $username = "";
  4. $password = "";
  5. $database = "";
  6.  
  7. // Connect to the database
  8. mysql_connect($hostname, $username, $password) OR DIE("Unable to connect");
  9. mysql_select_db("$database") or die("Unable to select database");
  10.  
  11. if (isset($_POST['ud_date'])) {
  12. $query = sprintf("UPDATE test_mysql SET content='%s' WHERE id=%d",
  13. mysql_real_escape_string($_POST['ud_date']),
  14. 2);
  15. if (mysql_query($query)) {
  16. echo 'update query succeeded';
  17. } else {
  18. echo 'update query failed';
  19. }
  20. } else {
  21. echo 'please submit the form';
  22. }

Add new comment