With much help from the manual, the below is what I have so far. What I am trying to do is update multiple records in a MySQL database depending on if the user has checked off a box or not in the aforementioned record. So far what I have will query the database, and put a check in the checkbox initially if the there is a “Y” in the correct database field.
[php]<?php
$con = mysql_connect(“localhost”,“root”,“root”);
if (!$con)
{
die('Could not connect: ’ . mysql_error());
}
mysql_select_db("test_db", $con);
$result = mysql_query("SELECT * FROM `logincheck` LIMIT 0, 30");
echo "<table border='1'>
<tr>
<th>Building</th>
<th>Room Number</th>
<th>Active</th>
</tr>";
while ($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['Building'] . "</td>";
echo "<td>" . $row['RoomNumber'] . "</td>";
if ($row['CheckLogin'] == 'N')
{
echo '<td><input type="checkbox" name="Active" value="'.$row['Active'].'" /></td>'."\n";
}
if ($row['Active'] == 'Y')
{
echo '<td><input type="checkbox" checked="yes" name="Active" value="'.$row['Active'].'" /></td>'."\n";
}
echo "</tr>";
}
echo "</table>";
echo '<input type="submit" name="button" id="button" value="Submit Changes" onClick="window.location = \'/testing/processing.php\'" />';
mysql_close($con);
?>[/php]
This is where I am stuck unfortunately. The submit button correctly sends to processing.php, and I put this there just so I knew it was doing something and I’d have some structure to work around.
[php]
<?php $con = mysql_connect("localhost","root","root"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("test_db", $con); $sql="INSERT INTO logincheck (Active) VALUES (0)"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "1 record added"; mysql_close($con); } ?>[/php]