oooh it's Monday Morning!!!!
You are not telling the select statement which record you want to edit!
PHP Code:
$idlast = $_GET['id'];
$select_sql = "SELECT * FROM links;
$result_sql = mysql_query($select_sql);
$row_sql = mysql_fetch_assoc($result_sql);
Should be...
PHP Code:
$idlast = $_GET['id'];
$select_sql = "SELECT * FROM links WHERE id = '$idlast'";
$result_sql = mysql_query($select_sql);
$row_sql = mysql_fetch_assoc($result_sql);
so now you are telling it which record you want to edit.
(If you copied my example, I missed off the closing " at the end of the statement! Sorry!)
Now your form will pick the correct record out of the database.
So now we have the record id, use the form to edit the data and resend it to the database...
PHP Code:
if(isset($_POST['submit'])) {
$url = $_POST['url'];
$name = $_POST['name'];
$category = $_POST['category'];
$updateSql = "UPDATE links SET url='$url' , name='$name' , category='$category' WHERE id='$idlast'";
$update_reult = mysql_query($updateSql) or die(mysql_error())";
}
Also on your form you need to name the input types as well as the submit button.
Code:
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
Id: <input type="text" name="id" value="<? echo $row_sql['id'];?>" size="5"><BR>
URL: <input type="text" name="url" value="<? echo $row_sql['url'];?>" size="58"><BR>
Title: <input type="text" name="name" value="<? echo $row_sql['name'];?>" size="25"><BR>
Category: <input type="text" name="category" value="<? echo $row_sql['category'];?>" size="25"><BR>
<input type="submit" name="submit" value="Update">
<td>
</table>
To conclude, your php page would look something like....
SQL select
if(isset($_POST['submit'])) {
SQL UPDATE
}
<html>
FORM
</html>
Any problems, post back
SpikeZ
Bookmarks