제출할 때마다 폴링 선택을 업데이트하고 싶습니다. 하지만 작동하지 않는 것 같습니다. 누구나 숨겨진 필드로 상태를 유지하는 것에 대해 조언 해 줄 수 있습니까? 및 설문 결과 테이블을 표시하려면 현재 페이지의 모든 내용을 지우는 방법은 무엇입니까?PHP : 숨겨진 파일로 상태를 유지하는 것에 대해 혼란 스럽습니다.
<?php
if ($_POST['choice']==0)
$a_count = $_POST['a_count']+1;
if ($_POST['choice']==1)
$b_count = $_POST['b_count']+1;
if ($_POST['choice']==2)
$c_count = $_POST['c_count']+1;
if ($_POST['choice']==3)
$d_count = $_POST['d_count']+1;
?>
<html>
<head>
</head>
<body>
<form action="index.php" method="POST">
<table align="center">
<tr><td>Please select</td></tr>
<tr><td><input type="radio" name="choice" value="0">aaaa</td></tr>
<input type="hidden" name="a_count" value="<?php print $a_count ?>">
<tr><td><input type="radio" name="choice" value="1">bbbb</td></tr>
<input type="hidden" name="b_count" value="<?php print $b_count ?>">
<tr><td><input type="radio" name="choice" value="2">cccc</td></tr>
<input type="hidden" name="c_count" value="<?php print $c_count ?>">
<tr><td><input type="radio" name="choice" value="3">dddd</td></tr>
<input type="hidden" name="d_count" value="<?php print $d_count ?>">
<tr><td><input type="submit" value="submit"></td></tr>
</table>
<table align="center" border="1" cellspacing="0">
<tr align="center"><th>Member Name</th><th>Vote</th></tr>
<tr><td>aaaa</td><td><?php echo"$a_count";?></td></tr>
<tr><td>bbbb</td><td><?php echo"$b_count";?></td></tr>
<tr><td>cccc</td><td><?php echo"$c_count";?></td></tr>
<tr><td>dddd</td><td><?php echo"$d_count";?></td></tr>
</table>
</form>
</body>
</html>
투표 결과를 데이터베이스에 저장해야합니다. PHP 변수는 모든 서버 요청 후에 지워집니다. – smilledge
해결책이 아니라면 실제로 무엇을 요구하고 있습니까? 상태를 유지하는 데는 여러 가지 방법이 있습니다. – ametren