截至一周前,这项工作有效,我不确定会发生什么变化。我们有一个电影数据库,带有一组单选按钮,可以为电影评分。每组单选按钮共享被评级电影的名称,因此每组都是一组不同的。点击提交时,会为每部电影添加一个评级表条目,但不会传递任何评级。
单选按钮代码:
<div id='stars'>
<input class='star star-6' id='{$NewID}-6' type='radio' name='{$row['MovieID']}' value='5'/>
<label class='star star-6' for='{$NewID}-6'></label>
<input class='star star-5' id='{$NewID}-5' type='radio' name='{$row['MovieID']}' value='4'/>
<label class='star star-5' for='{$NewID}-5'></label>
<input class='star star-4' id='{$NewID}-4' type='radio' name='{$row['MovieID']}' value='3'/>
<label class='star star-4' for='{$NewID}-4'></label>
<input class='star star-3' id='{$NewID}-3' type='radio' name='{$row['MovieID']}' value='2'/>
<label class='star star-3' for='{$NewID}-3'></label>
<input class='star star-2' id='{$NewID}-2' type='radio' name='{$row['MovieID']}' value='1'/>
<label class='star star-2' for='{$NewID}-2'></label>
<input class='star star-1 not' id='{$NewID}-1' type='radio' name='{$row['MovieID']}' value='notseen'/>
<label class='star star-1 not' for='{$NewID}-1'></label>
</div>
SQL更新代码:
$pushrating = "INSERT INTO Ratings (Username, MovieID, Rating) VALUES ('{$user}', '{$row['MovieID']}', '{$_POST[$row['MovieID']]}')";
mysqli_query($db, $pushrating);