如果选中或取消选中数组,请保存复选框提交

时间:2014-06-29 21:36:39

标签: php arrays checkbox

http://i.stack.imgur.com/TyC6U.png

我有类似这样的事情,当一个人选中一个复选框,然后点击按钮保存时,它会保存选中的复选框,下次当该人看到该表时,它会显示该表,其中包含该人检查的所有复选框或上次未经检查。我怎么能这样做?

这些月份在一个数组中,请检查我的代码:

<?php

$results = mysql_query("SELECT * FROM utilizadores");

$month = array("January","February","March","April","May","June","July","August","September","October","November","December");

echo '<form id="form" method="post" action="">';
echo '<table border="1" align="center">';
echo '<tr class="d0">';
echo '<td align="center" height="30" width="400"><strong>Nome</strong></td>';
for($i=0;$i<=11;$i++)
{
echo '<td align="center" width="80"><strong>'.@$month[$i].'</strong></td>';
}
echo '</tr>';
$rowColors = Array('#ffffff','#ffffcc'); $c= 0;
while($row = mysql_fetch_array($results)) {

echo '<tr style="background-color:'.$rowColors[$c++ % count($rowColors)].';">';
echo '<td align="center" height="30" width="400">' . $row['nome'] . "</td>";
for($i=0;$i<=11;$i++)     {     
echo '<td align="center" width="80"><input type="checkbox" name="asd" /></td>';
}
}
echo "</tr>";
echo "</table>";
echo "<br>";
echo '<input name="submit" type="submit" value="Save" />';
echo '</form>';

?>

<br />
</body>
</html>

0 个答案:

没有答案