Hello everyone!
Please I need help updating my database from a html form.
I'm quite new to PHP. I can't figure out where the error is.
Please can anyone help?
Thank you very much!
<body>
<?php
mysql_connect("localhost", "root", "");
mysql_select_db("wrapper");
if(isset($_POST['update'])){
$UpdateQuery = "UPDATE articles_selection SET article = '$_POST[article]' WHERE id ='$_POST[hidden]'";
mysql_query($UpdateQuery, $sql);
};
$sql = mysql_query("SELECT * FROM articles_selection");
echo "<table border = '1'>
<tr>
<th>ID</th>
<th>ARTICLE</th>
</tr>";
while($record = mysql_fetch_array($sql)){
echo "<form action="index1.php" method ="post">";
echo "<tr>";
echo "<td>" . "<input type = "text" name = "id" value =" . $record['id'] . " </td>";
echo "<td>" . "<input type = "text" name = "article" value =" . $record['article'] . " </td>";
echo "<td>" . "<input type = "hidden" name = "hidden" value =" . $record['id'] . " </td>";
echo "<td>" . "<input type = "submit" name = "Update" value = "update">" . " </td>";
echo "</tr>";
echo "</form>";
}
echo "</table>";
?>
</body>
Thank you very much!