Results 1 to 2 of 2

Thread: Update question

  1. #1
    Join Date
    Mar 2006

    Unanswered: Update question

    I have a form that displays data from my mysql database in text boxes in a table. Now im trying to update one field. But when i have more than row in the database, it only updates one row. ANy examples of a way to update data? I will have lots of records and need a way to update one field.
    thanks in advance



    mysql_connect ("localhost", "", "");
    @mysql_select_db($database) or die( "Unable to select database");
    $query = mysql_query( "SELECT * FROM login" )
    or die("SELECT Error: ".mysql_error());
    $num_rows = mysql_num_rows($query);
    print "There are $num_rows Clients in the Database.<P>";
    print "<table width=200 border=1>\n";
    print "<tr>\n";
    while ($row = mysql_fetch_array($query)) {

    $field = $row['username'];
    $field2 = $row['email'];
    $field3 = $row['paid'];
    $field4 = $row['id'];
    print "\t<td><input type=text name=T1 size=20 value= $field ></td>\n";
    print "\t<td><input type=text name=T2 size=20 value= $field2 ></td>\n";
    print "\t<td><input type=text name=T3 size=20 value= $field3 ></td>\n";
    print "\t<td><input type=text name=T4 size=10 value= $field4 ></td>\n";
    print "</tr>\n";
    print "</table>\n";

    Update page


    $username = $_POST['T1'];
    $paid = $_POST['T3'];
    $id = $_POST['T4'];

    @ $db2 = mysql_pconnect('localhost', '', '');

    mysql_select_db('winnings_win', $db2) or die(mysql_error());

    //set up the query
    $query = "UPDATE login SET paid = '$paid' WHERE id IN ( $id)";

    $result = mysql_query($query, $db2) or die('error making query');


  2. #2
    Join Date
    Apr 2005
    Baltimore, MD
    What is the value of $query right before you execute it?

Posting Permissions

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