#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Posts
    456
    Rep Power
    14
    I use this to add a new row of data to a table:

    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>$query = "insert into $parent values('$id','$author','$website','$fname','$width','$place','$title')";
    $result = mysql_query($query) or die("crap");[/code]

    The $id is an auto incrementing field so every row can be referenced with a unique number. Suppose I have the $id of the row I want to modify, and I have new values for $author, $website, $fname, $width, $place, and $title. What code do I use to modify the row (keeping the same $id)?

    Thanks!



    [This message has been edited by scream (edited July 07, 2000).]
  2. #2
  3. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Location
    Niagara Falls (On the wrong side of the gorge)
    Posts
    3,237
    Rep Power
    18
    You can do one of two things. You can use replace:

    $query="replace into $parent values($id,'$author','.... etc

    which will match where ANY field is a unique index (which auto_increment columns qualify for) or you can use update:

    $query="update $parent set author='$author',website='$website' ... etc... where id=$id";

    assuming column names there.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Posts
    456
    Rep Power
    14
    Thanks for the reply Rod. That did the trick!

    Later... Ryan

IMN logo majestic logo threadwatch logo seochat tools logo