SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Enthusiast AmandaArias's Avatar
    Join Date
    Sep 2001
    Location
    Houston, TX USA
    Posts
    82
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Query then update mysql database

    Hi all! I have the following code which works:

    PHP Code:
    if(isset($deletename)){ 

    // create SQL statement  to get newbw
    $thesql "SELECT * FROM clients WHERE id='$clientid'";
    $theresult mysql_query($thesql);
    $amandarow mysql_fetch_array($theresult);
    $variable $amandarow["variable"];
    //newvariable
    $variablenew $variable $passed_in_url_variable;


    //delete from anothertablename db
        
    $sql="DELETE FROM anothertablename WHERE username='$deletename'"
            if(@
    mysql_query($sql)){ 
            print(
    "<DIV ALIGN=\"center\"><BR><BR><B>SUCCESS</B></DIV>"); 
            }else{print(
    "Error deleting: mysql_error()"); 
             
            } 
        } 
    What I need to do is add another sql statement to occur at the same time but on the clients table. I need it to update $variable with $variablenew.

    Any ideas?

    Thanks much!

    Amanda

  2. #2
    if($awake){code();} PHP John's Avatar
    Join Date
    Jul 2002
    Location
    Along the Wasatch Fault line.
    Posts
    1,771
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Right now, with what I know, I would do this:

    get data from the client table.

    delete data from another table.

    update data in the client table.

    This would involve 3 separate queries.
    John

  3. #3
    SitePoint Enthusiast AmandaArias's Avatar
    Join Date
    Sep 2001
    Location
    Houston, TX USA
    Posts
    82
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the reply. So where within the code above would you stick the update query if you were me?

    Amanda
    Arias Web Hosting - Affordable, Multi-Domain Linux Hosting
    http://ariaswebhosting.com

    PhpShop Customization "Manual" - http://phpshop.ariaswebhosting.com/

  4. #4
    if($awake){code();} PHP John's Avatar
    Join Date
    Jul 2002
    Location
    Along the Wasatch Fault line.
    Posts
    1,771
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It really does not matter, as long as you do it BEFORE you require the updated information.
    John

  5. #5
    SitePoint Enthusiast AmandaArias's Avatar
    Join Date
    Sep 2001
    Location
    Houston, TX USA
    Posts
    82
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Cool. I got it working. Thanks!

    Amanda
    Arias Web Hosting - Affordable, Multi-Domain Linux Hosting
    http://ariaswebhosting.com

    PhpShop Customization "Manual" - http://phpshop.ariaswebhosting.com/

  6. #6
    if($awake){code();} PHP John's Avatar
    Join Date
    Jul 2002
    Location
    Along the Wasatch Fault line.
    Posts
    1,771
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No problem!
    John


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
  •