I have try to put together the following code to update a record.
I can not get the form to appear.
I need to use only one file to update the record.
What am I Doing wrong?
<html>
<body>
<?php
$name = "sample";
$db = mysql_connect("localhost", "mysite_admin", "admin");
mysql_select_db("mysite_admin",$db);
if ($submit) {
// here if no ID then adding else we're editing
if ($id) {
$sql = "UPDATE admin SET yourname='$yourname', youraddress='$youraddress', yourcity='$yourcity', yourpcode='$yourpcode', yourtel='$yourtel', youremail='$youremail', yourcontact='$yourcontact', yourbank='$yourbank', yourbranch='$ourbranch', yourbranchcode='$yourbranchcode', youraccount='$youraccount', farmname='$farmname', hunttype='$hunttype', subtitle='$subtitle', theme='$theme' WHERE ID='$id'";
}
// run SQL against the DB
$result = mysql_query($sql);
echo "Record updated/edited!<p>";
}
?>
<table>
<tr>
<form method="post" action="<?php echo $PHP_SELF?>">
<?php
if ($id) {
// editing so select a record
$sql = "SELECT * FROM admin WHERE mypassword=$name";
$result = mysql_query($sql);
$myrow = mysql_fetch_array($result);
$id=$myrow[0];
$yourname=$myrow[1];
$youraddress=$myrow[2];
$yourcity=$myrow[3];
$yourpcode=$myrow[4];
$yourtel=$myrow[5];
$youremail=$myrow[6];
$yourcontact=$myrow[7];
$yourbank=$myrow[8];
$yourbranch=$myrow[9];
$yourbranchcode=$myrow[10];
$youraccount=$myrow[11];
$farmname=$myrow[12];
$hunttype=$myrow[13];
$subtitle=$myrow[14];
$mypassword=$myrow[15];
$theme=$myrow[16];
// print the id for editing
?>
<input type=hidden name="id" value="<?php echo $id ?>">
<td>
Your Name:</td><td><input SIZE="60" type="Text" name="yourname" value="<?php echo $yourname ?>"><br>
</td></tr><tr><td>
Your Address:</td><td><input size="60" type="Text" name="youraddress" value="<?php echo $youraddress ?>"><br>
</td></tr><tr><td>
Your City:</td><td><input size="60" type="Text" name="yourcity" value="<?php echo $yourcity ?>"><br>
</td></tr><tr><td>
Your Postal Code:</td><td><input size="60" type="Text" name="yourpcode" value="<?php echo $yourpcode ?>"><br>
</td></tr><tr><td>
Your Tel Code & Number:</td><td><input size="60" type="Text" name="yourtel" value="<?php echo $yourtel ?>"><br>
</td></tr><tr><td>
Your E-Mail Address:</td><td><input size="60" type="Text" name="youremail" value="<?php echo $youremail ?>"><br>
</td></tr><tr><td>
Your Contact Persons Name:</td><td><input size="60" type="Text" name="yourcontact" value="<?php echo $yourcontact ?>"><br>
</td></tr><tr><td>
Your Bank Name:</td><td><input size="60" type="Text" name="yourbank" value="<?php echo $yourbank ?>"><br>
</td></tr><tr><td>
Your Branch Name:</td><td><input size="60" type="Text" name="yourbranch" value="<?php echo $yourbranch ?>"><br>
</td></tr><tr><td>
Your Branch Code:</td><td><input size="60" type="Text" name="yourbranchcode" value="<?php echo $yourbranchcode ?>"><br>
</td></tr><tr><td>
Your Account Number:</td><td><input size="60" type="Text" name="youraccount" value="<?php echo $youraccount ?>"><br>
</td></tr><tr><td>
Your Business Name:</td><td><input size="60" type="Text" name="farmname" value="<?php echo $farmname ?>"><br>
</td></tr><tr><td>
Your Hunter Type:</td><td><input size="60" type="Text" name="hunttype" value="<?php echo $hunttype ?>"><br>
</td></tr><tr><td>
Your Web Sub Title:</td><td><input size="60" type="Text" name="subtitle" value="<?php echo $subtitle ?>"><br>
</td></tr><tr><td>
Your Web Theme:</td><td><input size="2" type="Text" name="theme" value="<?php echo $theme ?>"><br>
</td></tr><tr><td>
<input type="Submit" name="personel" value="Enter information">
</td>
</tr>
</table>
</form>
<?php
}
?>
</body>
</html>