Hi,
I'm trying to get some mySQL table data into a form so I can edit it, and then insert the edited info back to the table. Here's the info I pass to my PHP code :
editRecord.php3?table=Testinput&ID=24
And here's the code it gets passed to :
<?php
$HTTP_GET_VARS['table'];
$HTTP_GET_VARS['ID'];
$db = mysql_connect("localhost", "outdoor");
mysql_select_db("Outdoors",$db);
if ($submit) {
$sql = "INSERT INTO Testinput (URL,SiteName,Description,Subcategory,Location,Status) VALUES (´$url´,´$sitename´,´$description´,´$subcategory´,´$location´,´$status´)";
}
?>
<form method="post" action="<?php echo $PHP_SELF?>">
<?php
if ($id) {
// editing so select a record
$sql = "SELECT * FROM $table WHERE ID=$id";
$result = mysql_query($sql);
$myrow = mysql_fetch_array($result);
$id = $myrow["ID"];
$url = $myrow["URL"];
$sitename = $myrow["SiteName"];
$description = $myrow["Description"];
$subcategory = $myrow["SubCategory"];
$location = $myrow["Location"];
$status = $myrow["Status"];
// print the id for editing
?>
<input type=hidden name="ID" value="<?php echo $id ?>">
<?php
}
?>
URL:<input type="Text" name="URL" value="<?php echo $url ?>"><br>
SiteName:<input type="Text" name="SiteName" value="<?php echo $sitename ?>"><br>
Description:<input type="Text" name="Description" value="<?php echo $description ?>"><br>
SubCategory:<input type="Text" name="SubCategory" value="<?php echo $subcategory ?>"><br>
Location:<input type="Text" name="Location" value="<?php echo $location ?>"><br>
Status:<input type="Text" name="Status" value="<?php echo $status ?>"><br>
<input type="Submit" name="submit" value="Enter information">
</form>
I get the following warning :
Warning: 0 is not a MySQL result index in /usr/local/etc/httpd/htdocs/editRecord.php3 on line 17
Any help on this would be greatly appreciated.
Thanks!
Mark