基本上,我的表单必须向已在页面中加载的表格中检查的注册用户添加积分。当用户点击提交按钮时,被选中的注册用户将获得额外的积分。我的问题是我不知道如何检索循环表中检查的行。这是我的代码。
<form name="blah" method="POST" action="">
<?php
include("mysql_config.php");
// INITIAL OUTPUT WHEN THE PAGE IS LOADED
echo "<table class='sample'><tr>
<td></td>
<td><b>User ID</b></td>
<td><b>Username</b></td>
<td><b>First Name</b></td>
<td><b>Last Name</b></td>
<td><b>Credits</b></td>
</tr>";
$q = "SELECT * FROM users_credits";
$res = mysql_query($q);
$num_rows = mysql_num_rows($res);
for($i=0; $i<$num_rows; $i++){
$db_field = mysql_fetch_assoc($res);
$reg_id = $db_field['reg_id'];
$credits = $db_field['credits'];
$q2 = "SELECT username, fn, ln FROM reg_users WHERE reg_id = $reg_id";
$res2 = mysql_query($q2);
$db_field2 = mysql_fetch_assoc($res2);
$username = $db_field2['username'];
$fn = $db_field2['fn'];
$ln = $db_field2['ln'];
echo "<tr>
<td><input type='checkbox' value='$i' name='add_credit'></td>
<td>$reg_id</td>
<td>$username</td>
<td>$fn</td>
<td>$ln</td>
<td>$credits</td>
</tr>";
}
?>
<input type="submit" name="save" value="Save" >
</form>
提前感谢会帮助我的人。:)