$as = mysql_query('SELECT u.id,u.username,c.score FROM user u, course c WHERE u.id = c.userid ');
echo '<form action="score.php" method="post"><table>';
while($row = mysql_fetch_array($as)
{
$uid = $row['id'];
$username = $row['username'];
$score = $row['score'];
echo '<tr><td>'.$username.'</td>
<td><input type="hidden" name="uid" value='.$uid.'>
<input type="text" name="score" value='.$score.'>
</td>
</tr>
}
echo '<tr><td><input type="submit" name="submit" value="update"></td></tr>';
echo '</table></form>';
if($_SERVER['REQUEST_METHOD == 'POST']
{
$uid = $_POST['uid'];
$score = $_POST['score'];
$sql = mysql('UPDATE user SET c.score = '.$score.' WHERE c.userid = '.$uid.'');
}
userid score
4 45%
3 30%
5 80%
它沒有更新表。我想呼應的變量,它是隻顯示最後一排,但我編輯的用戶3任何人都可以建議我哪裏錯了
你究竟在問什麼?你的代碼問題在哪裏? – Fluffeh 2012-08-01 08:17:28
注意:c.score是指已被分配了別名'c'的表格 – Waygood 2012-08-01 08:26:17