SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Guru Dashman's Avatar
    Join Date
    Jan 2006
    Location
    Manchester, UK
    Posts
    627
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Selecting the current record once insert query complete (MySQL)

    Hi guys ...

    I am writing a script that updates a record on the server, and am needing to select that same record right away.

    PHP Code:
    $s_totalplays "UPDATE tbl SET interactive = interactive+'1' WHERE user='".$user_id."'";
    $q_totalplays mysql_query($s_totalplays); 
    Is there an easy way for me to get all the new data (all fields) from this record, without performing another select query?

    Does this make sense?

    D

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,327
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    yes it makes sense and no there isn't, you have to SELECT

    by the way, please don't do arithmetic with strings
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Guru Dashman's Avatar
    Join Date
    Jan 2006
    Location
    Manchester, UK
    Posts
    627
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Rudy,

    Thanks for the swift reply.

    What would be the best way for me to add 1 to the current value of a field then?

    Many thanks,
    D

  4. #4
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    remove the quotes:
    PHP Code:
    $s_totalplays "UPDATE tbl SET interactive = interactive+1 WHERE user='".$user_id."'"
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  5. #5
    SitePoint Guru Dashman's Avatar
    Join Date
    Jan 2006
    Location
    Manchester, UK
    Posts
    627
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK, cheers for that ....


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
  •