我正在获取每条记录的单个 tsid 的值,但是数组中未返回选中的单选按钮值,我只得到 0?任何帮助表示赞赏。
PHP:
// Set the timesheets to set status approved/rejected
// find out how many records there are to update
$size = count($_POST['tsid']);
// start a loop in order to update each record
$i = 0;
while ($i < $size) {
// define each variable
$tsid = intval($_POST['tsid'][$i]);
$personnelid = intval($_POST['personnel'][$i]);
print "TSID: " . $tsid . "<br>";
print "TSuser: " . $personnelid . "<br>";
if ($tsid > 0 && $personnelid > 0) {
// do the update and print out some info just to provide some visual feedback
$query = "Update timesheets set status='1' where id= '$tsid' LIMIT 1";
mysql_query($query) or die ("Error in query: $query");
}
++$i;
}
mysql_close();
HTML:
<input type="hidden" name="tsid[]" value="<?PHP echo $row['id']; ?>">
<li data-role="fieldcontain">
<a href="tsapprove.php?id=<?PHP echo $row['id']; ?>"><p><?PHP echo $row['personnel']; ?></p>
<p><?PHP echo $row['name']; ?></p>
<p class="ui-li-aside"><strong><?PHP echo $row['totalhrs']; ?> H</strong></p>
<fieldset data-role="controlgroup" data-type="horizontal">
<input type="radio" name="personnel[]" id="1" value="<?PHP echo $row['personnel']; ?>" />
<label for="1">Approve</label>
<input type="radio" name="personnel[]" id="2" value="<?PHP echo $row['personnel']; ?>" />
<label for="2">Reject</label>
</fieldset>
</a>
<a href="tsapprove.php?id=<?PHP echo $row['id']; ?>">View Details</a>
</li>