Results 1 to 2 of 2

Thread: Update 2 records in the same time

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2002
    Posts
    259

    Update 2 records in the same time

    this code:
    $sql = "UPDATE members SET id = id + 1 WHERE id = '4'";

    to Update one record(id)

    but I want to update 2 records in the same time I use this code but it does not work:

    $sql = "UPDATE members SET id = id + 1,UserName=$username WHERE id = '4'";

    what is the error in this code ?

  2. #2
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    PHP Code:
    $sql "UPDATE members SET id = '$id + 1',UserName='$username' WHERE id = '4'"
    id = '$id + 1': You need to get the id and store it in a variable, $id. You can't just add like that. You also need to put singe quotes (') around the values, ie: "UserName='$username'"
    My evil laugh has a squeak in it.

    kristopherwilson.com

Posting Permissions

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



Click Here to Expand Forum to Full Width