I'm already displaying the MySQL data in a PHP table with a edit function, but I'm not able to edit them, and I don't know why.
<?php
require("db.php");
$id =$_REQUEST['rid'];
$result = mysql_query("SELECT * FROM replies WHERE rid = '$id'");
$test = mysql_fetch_array($result);
if (!$result)
{
die("Error: Data not found..");
}
$trigger1=$test['trigger1'] ;
$reply2= $test['reply2'] ;
if (isset($_POST['save']))
{
$triggera = $_POST['trigger1'];
$replyb = $_POST['reply2'];
mysql_query("UPDATE `replies`(trigger,reply) VALUES ('$triggera','$replyb') WHERE rid = '$id'");
echo "Saved!";
}
mysql_close($conn);
?>
And this is MySQL database code:
CREATE TABLE IF NOT EXISTS `replies` (
`trigger` text NOT NULL,
`reply` text NOT NULL,
`usercontrib` tinyint(4) NOT NULL DEFAULT '0',
`rid` int(10) unsigned NOT NULL
) ENGINE=MyISAM AUTO_INCREMENT=332 DEFAULT CHARSET=utf8;
and finally:
<form method="post">
<table>
<tr>
<td>Title:</td>
<td><input type="text" name="trigger" value="<?php echo $trigger1 ?>"/></td>
</tr>
<tr>
<td>Author</td>
<td><input type="text" name="reply" value="<?php echo $reply2 ?>"/></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="save" value="save" /></td>
</tr>
</table>
</form>
When I click "edit" in the specifically data to modify, the fields in the "edit" page are empty, I think the "echo" on thme is not function.