Hey, all of the errors are gone now. But it still will not output the variable to the input boxes. And id is a integer set to auto increment.
I cannot put the following statement into the page because I keep getting this error (Parse error: parse error, unexpected '}' in /home/html/update.php on line 23):
if(isSet($GET['id'])){
$id=$GET['id']
}else{ Line 23
$id = $_POST['id'];
}
Here is the code I have right now:
UPDATEFORM.PHP
<?
include("header.inc");
include("details.inc");
?>
<H2>Choose a Record to Update</H2>
<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)) {
print ("<TR ALIGN=CENTER><TD><A HREF=update.php?id=".$rs['id'].">Edit</A></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>");}
include("footer.inc");
?>
UPDATE.PHP
<?
include("header.inc");
?>
<H2>Update Database</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'];
if(isSet($GET['id'])){
$id=$GET['id']
}else{
$id = $_POST['id'];
}
$query="SELECT * FROM assets WHERE id='$id'";
$result=mysql_query($query);
print ($query);
mysql_query($query) or die (mysql_error());
if(isset($_POST['btnUpdate'])) {
$query = "UPDATE assets SET serialNum = '".$serial."', assetNum = '".$asset."', itemName = '".$name."',location = '".$location."', description = '".$description."',warranty = '".$warranty."' WHERE id = ".$id;
mysql_query($query) or die (mysql_error());
echo $query;
mysql_close();
}
?>
<form method="post" action="<?php echo $PHP_SELF; ?>">
<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=<? echo $rs['itemName'] ?>></TD>
</TR>
<TR ALIGN=CENTER>
<TD><B>Serial Number</B></TD><TD><Input type="text" name="serial" size="20" value=<? echo $rs['serialNum'] ?>></TD>
</TR>
<TR ALIGN=CENTER>
<TD><B>Asset Number</B></TD><TD><Input type="text" name="asset" size="20" value=<? echo $rs['assetNum'] ?>></TD>
</TR>
<TR ALIGN=CENTER>
<TD><B>Location</B></TD><TD><Select name="location" value="<? echo $rs['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=<? echo $rs['description'] ?>></TD>
</TR>
<TR ALIGN=CENTER>
<TD><B>Warranty</B></TD><TD><Input type="text" name="warranty" size="20" value=<? echo $rs['warranty'] ?>></TD>
</TR>
</TABLE>
<BR><CENTER>
<input type="Submit" name="btnUpdate" Value="Update Record">
<input type="Reset" name="Reset">
</FORM></CENTER>
<?
include("footer.inc");
?>