嗨,我这里有一个项目清单。这是过滤字段以生成报告。
<form action="" method="post">
<?php
if (isset($_POST['report'])){
if(empty($_POST['check_list'])){
echo "Please select field!<br/>";
}
if(!empty($_POST['check_list'])){
$id= array_reverse($_POST['check_list']);
print_r($id);
foreach($id as $key => $report_id){
$s = $report_id . ',' . $s;
}
//echo $s;
$xfields = substr($s, 0, strlen - 1);
echo $xfields . ' was/were checked! <br/>';
$x = substr_count($xfields, ',');
echo '<table width=100% border=1>';
echo '<tr>';
$field_list = explode(',', $xfields);
for ($i = 0; $i <= $x; $i++)
{
echo '<th>' . $field_list[$i] . '</th>';
}
echo '</tr>';
$sql = 'select ' . $xfields . ' from areentry WHERE TagId = 1' ;
//echo $sql;
$rst = mysql_query($sql);
if (!$rst) {
echo 'Could not run query: ' . mysql_error();
exit;
}
if (mysql_num_rows($rst) > 0) {
while( $xrow = mysql_fetch_array( $rst ) ) {
echo '<tr>';
for ($i = 0; $i <= $x; $i++)
{
echo '<td>' . $xrow[$i] . '</td>';
}
}
echo '</tr>';
}
echo '</table>';
return;
}
}
if (mysql_num_rows($result) > 0) {
echo '<table border=1>';
echo '<ul>'.NL;
while( $row = mysql_fetch_array( $result ) ):
echo '<tr><td><input type=checkbox name=check_list[] value=' . $row[0] . '>' . $row[0] . '</td></tr>';
endwhile;
echo '</table>';
}
?>
复选框选项如下所示,在选择字段后,它会生成包含检查字段的报告
我如何确定要检查的第一项是什么?
答案 0 :(得分:1)
$checked_list=$_POST['check_list'];
if(empty($checked_list){
echo "Please select field!";
}else{
for($i=0;$i<count($checked_list);$i++){
echo $checked_list[$i]."Checked";
}
}
希望它有用......