Doug, One way to handle this is the following: On the page that lists the people, under the edit link, you put something like <a href="editscript.php?id=$id">Edit</a>. When the user clicks that link, the $id will be passed in the URL. In your editscript.php page, inside the form where you're editing the information, you create an <input type="hidden" name="updateThisRecord" value="<?php $_GET['id'] ?>"> (or some variation thereof depending on how your HTML is handled). This will place the ID into a hidden field that can be passed to your update query via POST. When the user hits the submit button, all of your form data can be used in the UPDATE query and you just add a WHERE clause to the end of it. For example: "UPDATE personTable SET ...your column names and values here... WHERE id=".$_POST[updateThisRecord].""; I'm sure there are other ways of handling this, but I've had success with this methodology in the past. None of the code in here has been tested or anything - just straight off the top of my head so I apologize in advance if everything doesn't work verbatim. Hope this helped. Rich > -----Original Message----- > From: Hull, Douglas D [mailto:ddhull@ku.edu] > Sent: Friday, July 18, 2003 11:40 AM > To: Note To php mysql List (E-mail) > Subject: Passing key field, id, from form to procedure > > > I am just starting to learn php and mysql. I have a small > php/html page and > database. All it does when starting shows the name of each > person with a > delete and edit link beside each name. At the bottom of the > list there is > an "Add Record" button. If you select delete it takes out > the name and > reloads the page. If you select "Add Record" it brings up a > form to add a > new name etc. with an "Add It" button under the form in which after > selecting INSERTs the new record and reloads the initial > page. The add and > delete parts work fine. > > The edit record is the problem. After selecting the edit beside the > appropriate name a form is brought up showing the current > information for > that record with an "Update Record" button under the form. > This works fine > to here. But when I select the "Update Record button it will > go into the > "updaterecord" procedure of my php/html page but it has no id > for it to > apply the UPDATE to. So how can I have it pass the id to the > "updaterecord" > procedure so it will apply the UPDATE to the appropriate > record? I tried > two different ways of getting the id for updaterecord as you > can see below. > Following is my editrecord and updaterecord procedures: > > if (isset($_GET['editrecord'])) { //edit record > $zid = $_GET['editrecord']; > $sql = "SELECT * FROM persinfo WHERE DID = $zid"; > $result = mysql_query($sql); > $row = mysql_fetch_array($result); > $zid = $row["DID"]; > $zfname = $row["DFirst"]; > $zlname = $row["DLast"]; > ?> > <form action="<?=$_SERVER['PHP_SELF']?>" method="post"> > <input type=hidden name='DID' value="<? echo $zid; ?>"> > First name: <input type="text" name="zfname" > value="<? echo $zfname; ?>"/> <br> > Last name: <input type="text" name="zlname" > value="<? echo $zlname; ?>"/> <br> > <input type="submit" name="updaterecord" value="Update It" /> > </form> > <?php } ?> > > <?php > if (isset($_GET['$updaterecord'])) { > //update record > version 1 > $zid = $_GET['$updaterecord']; > $sql = "UPDATE persinfo SET DFirst='$zfname', > DLast = '$zlname' WHERE DID=$zid"; > $result = mysql_query($sql); > } > } > > //I also tried this > > if ($updaterecord) { > //update > record version 2 > if ($zid) { > $sql = "UPDATE persinfo SET DFirst='$zfname', > DLast = '$zlname' WHERE DID=$zid"; > $result = mysql_query($sql); > } > } > ?> > > If you want all of the code let me know. I could send it to > your personal > email address. The whole thing is probably 130 lines of code. > > Thanks for any help, > Doug Hull > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php