Sorry, coming in to this thing a little late; and I'm still not sure I fully understand what you want, but here goes. Try the following:
Code:
<?php
$DBserver = "localhost"; //change to match your db server
$DBuser = "username"; //change to your db username
$DBpass = "password"; //change to your db password
$DB = "news"; //change to your db
$table = "news"; //change to the table in the db
$conn = mysql_connect($DBserver, $DBuser, $DBpass);
mysql_select_db($DB);
if ($_POST['action'] == "update") { //if form was submitted, update table
$id = $_POST['id'];
$text1 = $_POST['text1'];
$text2 = $_POST['text2'];
mysql_query("UPDATE `$table` SET `text1`= '$text1', `text2` = '$text2' WHERE `id` = '$id'");
header('Location: '.$_SERVER["PHP_SELF"]);
}
else { //if form not submitted, display form
$info = mysql_query("SELECT * FROM `$table` WHERE `id` = '$id'");
$qry = mysql_fetch_array($info);
?>
<form action="<?php echo $_SERVER['PHP_SELF'];?>" method="POST">
<input type="hidden" name="action" value="update">
<input type="hidden" name="id" value="<?php echo $_REQUEST['id'];?>">
Text 1: <input type="text" name="text1" value="<?php echo $qry['text1'];?>">
Text 2: <input type="text" name="text2" value="<?php echo $qry['text2'];?>">
<input type="submit" value="Update Info">
</form>
<?php
}
?>
Hope this is something like what you wanted. To get it to work properly, you would need to call the page like so:
Where "id" (in red) is the id that identifies the row for which you are trying to update.
Sorry for not explaining much more, short on time right now. If you need any further help, let me know or perhaps another member could help you further.
Hope this helps.
Bookmarks