I am making a web form for entering/editing/deleting items from a database, the entering and deleting parts work fine. The editing part is giving me some problems - Here's the code - ------------ <? include "connect"; if ($submit) { // if no ID then we're adding a new rma, else we're editing an existing rma if ($id) { $sql = "UPDATE rma SET rma_no='$rma_no',rma_name='$rma_name',rec_date ='$rec_date',rma_status='$rma_status' WHERE id='$id'"; } else { $sql = "INSERT INTO rma (rma_no,rma_name,rec_date,rma_status) VALUES ('$rma_no','$rma_name','$rec_date','$rma_status')"; } // run SQL against the DB $result = mysql_query($sql); echo "Record updated/edited!<p> <a href=\"rma_input.php\">List RMA's</a>"; } elseif ($delete) { // delete a record $sql = "DELETE FROM rma WHERE id=$id"; $result = mysql_query($sql); echo "Deleted!<p><a href=\"rma_input.php\">List RMA's</a></p>"; } else { // this part happens if we don't press submit if (!$id) { // print the list if there is not editing $result = mysql_query("SELECT * FROM rma",$db); while ($myrow = mysql_fetch_array($result)) { printf("<a href=\"%s?id=%s\">%s %s</a> \n", $PHP_SELF, $myrow["id"], $myrow["rma_no"], $myrow["rma_name"], $myrow["rec_date"], $myrow ["rma_status"]); printf("<a href=\"%s?id=%s&delete=yes\">(DELETE)</a><br>", $PHP_SELF, $myrow["id"]); } }
if ($id) { // editing so select a record $sql = "SELECT * FROM rma WHERE id=$id"; $result = mysql_query($sql); $myrow = mysql_fetch_array($result); $id = $myrow["id"]; $rma_no = $myrow["rma_no"]; $rma_name = $myrow["rma_name"]; $rec_date = $myrow["rec_date"]; $rma_status = $myrow["rma_status"]; // print the id for editi ?> <input type=hidden name="id" value="<?php echo $id ?>"> <? } } ?> -------------------- What is happening is when I click on an item on the list it will display all the fields except rma_status (a textarea form field). When I make any changes and press submit, the changes to fields other than rma_status, those fields are updated or left as is, but the rma_status textarea is wiped out. Also, instead of updating the current item in the db, it is submitting another row into the database, giving multiple rows of the same rma, but with each one showing it's edits over time. This would be fine for historical purposes, but not what I want. What am I doing wrong? -- Chip Wiegand Computer Services Simrad, Inc www.simradusa.com [EMAIL PROTECTED] "There is no reason anyone would want a computer in their home." --Ken Olson, president, chairman and founder of Digital Equipment Corporation, 1977 (They why do I have 9? Somebody help me!) -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php