Quote:
Originally Posted by Fou-Lu
No don't loop it like this; limit SQL to as few requests as you possibly can. In the case of an UPDATE, you can use an IN clause for the WHERE condition.
What is the $_POST['group'] to $_POST['check'] relationship? As in, it sounds like you have many perticipant's available, and potentially many groups, so what does that look like structurally from your HTML?
|
This is the body of my HTML:
<body>
<form name="myform" id="myform" action="" method="POST">
<label for="group" id="group_label">Group Name: </label>
<input type="text" name="group" maxlength="45" id="group" value=""/>
<br><br>
Member List:<br><br>
<?php
$query = mysql_query('SELECT * FROM `Participant`');
if (!$query)
{
die('Query failure: '.mysql_error());
}
while($rows = mysql_fetch_array($query)):
$id = $rows['idParticipant'];
$fname = $rows['firstName'];
$sname = $rows['secondName'];
$facility = $rows['facility'];
echo "<input type='checkbox' name='check' id='$id' value='$id' /><br>";
echo "First Name: $fname<br>";
echo "Second Name: $sname<br>";
echo "Facility: $facility<br><br>";
endwhile;
?>
<input type="submit" name="submit" value="Save New Group">
</form>
<form>
<input type="button" value="Back" onclick="window.location.href='home.php'">
</form>
</body>
Not sure what you mean by the relationship between $_POST['group'] and $_POST['check']? We need the $_POST['group'] so we know what to insert into the group column of the chosen participants in the list. And we need the $_POST['check'] so we know which participants need to be updated. That make sense?