I am a complete newbie to php and mysql. I am just trying to achieve something simple right now as a test.
I have a Mysql database with 3 columns (Chapter, Editor, Approved). Using form I have managed to get these to show on a page to allow someone to change the relevant details then submit them. The problem is when the page updates it shows the old details - ie the changes are not stored. I am sure I am doing something incredibly stupid but after 2 hours can’t see it. I’m sure someone with some knowledge will spot it in a heartbeat. The necessary code.
The page to show the info
<?php
include_once ‘includes/dbh_progress.inc.php’;
?>
<html>
<head>
<title>Update progress</title>
</head>
<body>
<?php
//connect to dbase
//done in inc file
//select database - in inc file?
//mysqli_select_db($conn,'progress');
//select query
$sql="SELECT * FROM VM;";
//execute query
$records=mysqli_query($conn,$sql);
?>
<table>
<tr>
<th>Chapter</th>
<th>Staff</th>
<th>Approved for submission</th>
</tr>
<?php
while($row=mysqli_fetch_array($records))
{
echo "<tr><form action=update.php method=post>";
echo "<td><input type=text name=chapter_i value='".$row['Chapter']."'</td>";
echo "<td><input type=text name=editor_i value='".$row['Editor']."'</td>";
echo "<td><input type=date name=submission_i value='".$row['Approved']."'</td>";
echo "<td><input type=submit>";
echo "</form></tr>";
}
?>
</table>
</body>
</html>
update.php
<?php
include_once 'includes/dbh_progress.inc.php';
//connect to dbase
//done in inc file
//select database - in inc file?
//mysqli_select_db($conn,'progress');
//update query
$sql="update VM set Approved='$submission_i' WHERE Chapter='$Chapter'";
//can use comma and another for each variable
//execute query
if(mysqli_query($conn,$sql))
header("refresh:1; url=test_update.php");
else
echo "NO";
?>
The primary key is chapter. If you need anything more please yell. TIA