www.webdeveloper.com
Results 1 to 4 of 4

Thread: How do I update more than 1 column at a time?

  1. #1
    Join Date
    Jan 2004
    Posts
    312

    How do I update more than 1 column at a time?

    I am pulling the info from form inputs. For some reason I can't get more than 1 entry to to be updated, can someone guide me in the right direction for my "query"?

    Thanks.

    PHP Code:
    <?php

    //connection information 
    $ser="server"$db="database"$user="username"$pass="password";

    //sql connection 
    $conn odbc_connect($db$user$pass);  

    $query"UPDATE database SET Column1 = '$Column1' WHERE Company_Name='$Company_Name'";

    odbc_do($conn$query);
    ?>

    <html>

    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>Form</title>
    </head>
    <body>

    </body>
    </html>
    <?php
    odbc_close
    ($conn); 
    ?>

  2. #2
    Join Date
    Mar 2004
    Location
    London, UK
    Posts
    342
    Separate the entries by a comma,

    PHP Code:

    $query
    "UPDATE database SET Column1 = '$Column1', Column2 = '$Column2', Column3 = '$Column3' WHERE Company_Name='$Company_Name'"

  3. #3
    Join Date
    Jan 2004
    Posts
    312

    Done

    Thanks so much solavar, that did it, your a lifesaver!

  4. #4
    Join Date
    Dec 2002
    Location
    High on life
    Posts
    10,104
    You might even want to structure your query better, by using backticks around the field/table names. It can help save you some grief if you start using more complex SQL statments...

    PHP Code:
    $query "UPDATE `database` SET `Column1` = '$Column1', `Column2` = '$Column2', `Column3` = '$Column3' WHERE `Company_Name` = '$Company_Name';"

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles