Hi PHP Freaks. Noobie here. Trying to learn PHP, following lecturesnippets.com PHP lessons. This is lesson 38. This seems like it should be simple, but no matter what I do, I can't get the database to update. Any help would be greatly appreciated. Thanks. Here's my code right now:
<html>
<head>
</head>
<body>
<?php
$con = mysqli_connect("localhost","Eric","******");
if (!$con){
die("Cannot connect:" . mysqli_connect_error());
}
mysqli_select_db($con,"snippets");
if (isset($_POST['update'])){
$UpdateQuery = "UPDATE lectures SET Topic = '$_POST', Name='$_POST[name]', Attendance= '$_POST[attendance]' WHERE Topic='$_POST[hidden]'";
mysqli_query($con,$UpdateQuery);
};
$sql = "SELECT * FROM lectures";
$myData = mysqli_query($con,$sql);
echo "<table border=1>
<tr>
<th>Topic</th>
<th>Name</th>
<th>Attendance</th>
</tr>";
while($record = mysqli_fetch_array($myData)){
echo"<form action=mydata3.php method=post>";
echo "<tr>";
echo "<td>" . "<input type=text name=topic value=" . $record['Topic'] . "> </td>";
echo "<td>" . "<input type=text name=name value=" . $record['Name'] . "> </td>";
echo "<td>" . "<input type=text name=attendance value=" . $record['Attendance'] . "> </td>";
echo "<td>" . "<input type=hidden name=hidden value=" . $record['Topic'] . "> </td>";
echo "<td>" . "<input type=submit name=submit value=update" . "> </td>";
echo "</form>";
}
echo"</table>";
mysqli_close($con);
?>
</body>
</html>