Hey guys,
I've come across a small problem. In my php page, a link called edit gets spit out in front of every record so that record can be updated. When you click on it, it should take you to an update page and load details (according to what you clicked) into the input boxes. This is the problem. How do I go about getting the program to know what to load? Here is my code (some of what I have done may be completely wrong so feel free to cut what isn't needed):
updateForm.php:
<?
include("header.inc");
include("details.inc");
?>
<H2>Update a Record</H2><P><HR><P>
<A HREF="enterForm.php">Enter a Record</A>
<A HREF="searchForm.php">Search Database</A>
<A HREF="userForm.php">Create a New User</A><P><HR></CENTER><P>
<?
include("title.inc");
$query="SELECT * FROM assets ORDER BY location ASC";
$result=mysql_query($query);
while ($rs = mysql_fetch_array($result)) {
printf("<TR ALIGN=CENTER><TD><A HREF=update.php>Edit</A><input type='hidden' name='itemID' value='[$id]'></TD><TD>" . $rs['itemName'] . "</TD><TD>" . $rs['serialNum'] . "</TD><TD>" . $rs['assetNum'] . "</TD><TD>" . $rs['location'] . "</TD><TD>" . $rs['description'] . "</TD><TD>" . $rs['entryDate'] . "</TD><TD>" . $rs['warranty'] . "</TD></TR>");
}
mysql_close();
include("footer.inc");
?>
update.php:
<?
include("header.inc");
?>
<H2>Display results</H2><P><HR>
<P>
<A HREF="enterForm.php">Enter a Record</A>
<A HREF="searchForm.php">Search Database</A>
<A HREF="userForm.php">Create a New User</A><P><HR></CENTER><P>
<?
include("details.inc");
$asset = $POST['asset'];
$name = $POST['name'];
$location = $POST['location'];
$description = $POST['description'];
$warranty = $POST['warranty'];
$serial = $POST['serial'];
$id=$_POST['itemID'];
if(isset($_POST['btnUpdate'])) {
$query = "UPDATE assets SET
serialNum = '$serial',
assetNum = '$asset',
itemName = '$name',
location = '$location',
description = '$description',
warranty = '$warranty'
WHERE id LIKE '$id'";
mysql_query($query) or die (mysql_error());
}
?>
<TABLE BORDER=1 WIDTH=40% ALIGN="CENTER">
<TR ALIGN=CENTER>
<TD><B>Item Name</B></TD><TD><Input type="text" name="name" size="20" value=<?$name?>></TD>
</TR>
<TR ALIGN=CENTER>
<TD><B>Serial Number</B></TD><TD><Input type="text" name="serial" size="20" value=<?$serial?> ></TD>
</TR>
<TR ALIGN=CENTER>
<TD><B>Asset Number</B></TD><TD><Input type="text" name="asset" size="20" value=<?$asset?>></TD>
</TR>
<TR ALIGN=CENTER>
<TD><B>Location</B></TD><TD><Select name="location" value="location">
<OPTION>
<OPTION>Baie Verte
<OPTION>Botwood
<OPTION>Bishop Falls
<OPTION>Buchans
<OPTION>Carmanville
<OPTION>Centreville
<OPTION>Change Islands
<OPTION>Fogo Island
<OPTION>Gambo
<OPTION>Gander
<OPTION>Gaultois
<OPTION>Glenwood
<OPTION>Glovertown
<OPTION>Grand Falls
<OPTION>Greenspond
<OPTION>Harbour Breton
<OPTION>Hare Bay
<OPTION>Harry's Harbour
<OPTION>Hermitage
<OPTION>King's Point
<OPTION>La Scie
<OPTION>Lewisporte
<OPTION>Lumsden
<OPTION>Musgrave Harbour
<OPTION>Norris Arm
<OPTION>Point Leamington
<OPTION>Robert's Arm
<OPTION>Seal Cove
<OPTION>Springdale
<OPTION>St. Alban's
<OPTION>Summerford
<OPTION>Twillingate
<OPTION>Wesleyville
</SELECT></TD>
</TR>
<TR ALIGN=CENTER>
<TD><B>Description</B></TD><TD><Input type="text" name="description" size="20" value=<?$description?>></TD>
</TR>
<TR ALIGN=CENTER>
<TD><B>Warranty</B></TD><TD><Input type="text" name="warranty" size="20" value=<?$warranty?>></TD>
</TR>
</TABLE>
<BR><CENTER>
<input type="Submit" name="btnUpdate" Value="Update Record">
<input type="Reset" name="Reset">
</FORM></CENTER>
<?
include("footer.inc");
?>