Here's my table:
id | name | check
------------------
1 | Paul | no
2 | Bob | no
3 | Tom | no
id is an INT, name and check TEXT.
Here's the script:
<?php
include("database.php");
$dbc= new dbClass();
$query = $dbc->dbRunSql("select * from names order by name");
while ($result = mysql_fetch_array($query)){ ?>
<form method="POST" action="">
<input type="checkbox" name="names[]" value="yes"/><?php echo $result['name'];
} ?>
<br>
<input name="submit" type="submit" />
</form> <?php
if(isset($_POST["submit"])){
foreach ($_POST['names'] as $entry){
$dbc= new dbClass();
$query = $dbc->dbRunSql("update `names` set `check`='$entry';");
}
}
?>
This script works but updates all the rows, not the ones I check.
I have 2 questions:
1) What should I change to make it work correctly? (updating the ones that I check)
2) The ones that I don't check, how to update them in the "check" column as "no"
I hope you could understand what I meant.
Thanks in advance.