|
-
Dec 4th, 2005, 11:31 AM
#1
Thread Starter
Lively Member
Editing Data
hey, i'm having abit of trouble with editing data, what i want to do is
Code:
<?php
if (isset($action) && $action == 'edit') {
?>
<?php
$data = mysql_query( "SELECT * FROM tbl_test ORDER BY id", $db ) or die(mysql_error());
while ( $row = mysql_fetch_array( $data ) ) {
print "<a href=\"user_form.php?action=edit&do=edit&id=" . $row['id'] . "<br>";
}
if (isset($action) && $do == 'edit') {
$result = mysql_query("SELECT * FROM tbl_test WHERE id='$id'",$db) or die(mysql_error());
while ( $row = mysql_fetch_array( $result ) ) {
//$fname = $result['fname'];
//$sname = $result['sname'];
}
}
if (isset($action) && $action == 'update') {
mysql_query( "UPDATE `tbl_test` SET `fname` = '$fname', `sname` = '$sname' WHERE `id` =$id LIMIT 1 ;", $db ) or die(mysql_error());
}
?>
<form action="<?php $_SERVER['PHP_SELF']; ?>?action=update&action=edit" method="post">
Enter ID:<input type="text" name="id" id="id" value="<?php echo $id; ?>"><br />
Forename:<input type=text name="sname" value="<?php echo $fname; ?>"><br />
Surname:<input type=text name="fname" value="<?php echo $sname; ?>"><br />
<input type="submit" value="Save new data">
</form>
<?php
}
//****************** End of Editing Data ******************************
?>
i got it displaying the list, but i just need it to when you click the id number, it puts the first and second name into the text boxes, then when you hit edit it saves the changes
thanks for any help
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|