我的老师说我必须使用 for 循环来显示单选按钮的名称。它会这样做,但它不计算单选按钮被选中的次数。所以它不提交选票。这是一个学校项目。这是代码:
if(isset($_POST['verzenden'])) {
$name= "item_" . $data2['id'];
for($name = item_0; $name <= item_28; $name++){
$query="UPDATE optie SET stemmen= stemmen + 1 WHERE id= '$name'";
if(mysql_query($query)){
echo"Stem opgeslagen! <br /><br/>";
} else {
echo"Fout tijdens opslaan stem!<br /><br/>";
} }}
$result = mysql_query("SELECT * FROM poll");
while($data = mysql_fetch_assoc($result)){
echo"<b>" . $data['vraag'] . "</b><br/><br />";
echo"<form method='post' action=''>";
echo "<fieldset>";
$result2 = mysql_query("SELECT * FROM optie WHERE poll ='" . $data['id'] . "'");
while($data2 = mysql_fetch_assoc($result2)){
echo "<input type='radio' name='item_" . $data2['id'] . "' value='" . $data2['id'] . "'/>" . $data2['optie'] . "<br />";
}
echo"<br/>";
echo"</fieldset>";
}
?>
</form>
<?php
我希望有一个人可以帮助我,
再见凯瑟琳