The following PHP code create a simple 2×2 table along with a check box for each row.
Using JavaScript, how do I create a script, that ‘Checks All’ check boxes upon the top (title) check box being clicked, then if the top (title) check box is clicked again, ‘Clears All’ check boxes?
[code=php]<?php
$con = mysql_connect(“localhost”,”peter”,”abc123″);
if (!$con)
{
die(mysql_error());
}
mysql_select_db(“db”, $con);
$result = mysql_query(“SELECT * FROM person”);
echo ‘<table border=”1″>
<tr>
<th><input type=”checkbox” name=”checkbox” value=”checkbox”></th>
<th>First Name</th>
<th>Last Name</th>
</tr>’;
while($row = mysql_fetch_array($result))
{
echo ‘<tr>’;
echo ‘<td><input type=”checkbox” name=”checkbox” value=”checkbox”></td>’;
echo ‘<td>’.$row[‘FirstName’].'</td>’;
echo ‘<td>’.$row[‘LastName’].'</td>’;
echo ‘</tr>’;
}
echo ‘</table>’;
mysql_close($con);
?>