Loading

Problem to update table in mysql using php

Submitted by: 


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

(If you're a human, don't change the following field)
Your first name.
(If you're a human, don't change the following field)
Your first name.

Filtered HTML

  • You may insert videos with [video:URL]
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <asp>, <c>, <cpp>, <csharp>, <css>, <html4strict>, <java>, <javascript>, <mysql>, <php>, <python>, <sql>, <vb>, <vbnet>. The supported tag styles are: <foo>, [foo].
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.