Php 数组定位以生成报告
嗨,我这里有一个项目清单。用于筛选字段以生成报告Php 数组定位以生成报告,php,arrays,Php,Arrays,嗨,我这里有一个项目清单。用于筛选字段以生成报告 <form action="" method="post"> <?php if (isset($_POST['report'])){ if(empty($_POST['check_list'])){ echo "Please select field!<br/>"; } if(!empty($_POST['check_list
<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>';
}
?>
复选框选项如下所示,选择字段后,它将生成包含已选中字段的报告
如何确定要检查的第一个项目是什么?$checked\u list=$\u POST['check\u list'];
$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";
}
}
if(空($checked\u列表){
echo“请选择字段!”;
}否则{
对于($i=0;$ithanks),它只显示有支票的项目,我需要知道哪个框先有支票