SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Guru
    Join Date
    Apr 2001
    Location
    BC, Canada
    Posts
    630
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey..
    on the updating side of things..
    whats the query to update a value in MYSQL

    I know hte first part is
    Update table Set
    but after that im lost

    Thanx
    Ryan Lahay

  2. #2
    SitePoint Enthusiast
    Join Date
    Feb 2001
    Location
    Monmouth Junction, NJ
    Posts
    88
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    mysql_query("UPDATE mysqldb SET field='$variable', field2='$variable2'");

  3. #3
    SitePoint Guru
    Join Date
    Apr 2001
    Location
    BC, Canada
    Posts
    630
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    what about the WHERE part
    dont i need to say what row to make the changes on?

  4. #4
    SitePoint Enthusiast
    Join Date
    Feb 2001
    Location
    Monmouth Junction, NJ
    Posts
    88
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    mysql_query("UPDATE mysqldb SET field='$variable', field2='$variable2' WHERE field='$condition'");

  5. #5
    SitePoint Wizard edshuck's Avatar
    Join Date
    Jul 2000
    Posts
    1,200
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi

    Add the where part just on the end of the query from GoD.

    mysql_query("UPDATE mytable SET field='$variable', field2='$variable2' WHERE field3='$variable3'");

    Lets say I have a bibliography and have Tom Clancy as the author of Red Storm Running and want to change it to Red Storm Rising and the bib_id=677.

    UPDATE bib SET title='Red Storm Rising' WHERE bib_id='677';

    The bib_id is a good idea. Rather than specing Clancy, who may have other titles. Just an example.

    I have left it off when working directly over telnet and have had immediate and deep regrets.

    While I was writing this, GoD posted. Sorry.

    peace

  6. #6
    SitePoint Guru
    Join Date
    Apr 2001
    Location
    BC, Canada
    Posts
    630
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanx
    its great to finnaly find a forum that actually helps people



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
  •