Results 1 to 2 of 2

Thread: update multiple feilds

  1. #1
    Join Date
    Jun 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default update multiple feilds

    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 Code:
    <?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.

  2. #2
    Join Date
    Jun 2012
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    first of all you have mistake in line 18

    else echo 'update query failed';

    remove else

    second

    follow this might help you

    http://www.phpeasystep.com/mysql/10.html

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •