我已经创建了一个过滤器功能,但是我在使用起始表时遇到了问题,如果没有为过滤器选择类别,我希望显示从表中选择的所有数据。到目前为止,如果选择了一个类别,我可以显示所有需要的数据,但前提是选择了一个类别。如果没有选择,它会显示一个空白表。请帮忙,...
这是功能
function listhistoryHost(){
$accountid=$_SESSION['userid'];
if(isset($_POST['button'])){
$filter=$_POST['historyfilter'];
if($filter==$filter){
$sql="select * from webhostrequest where status='$filter' order by webhostrequest.recentact desc";
$result=mysql_query($sql) or die("Error in selecting items ".mysql_error());
$out="<ul>";
while($row=mysql_fetch_array($result)){
$accountid=$row['userid'];
$requesttitle=$row['requesttitle'];
$requestid=$row['requestid'];
echo "<table width=\"100%\" border=\"0\" cellpadding=\"2\">";
echo "<tr class=\"rowcolor1\">";
echo "<td width=\"70%\"><span style=\"padding-left:20px\">Requested Web Hosting for ".$row["requesttitle"]. "</td>";
echo "<td width=\"20%\"><span style=\"padding-left:20px\">Status: " .$row["status"]. "</td>";
echo "<td>
<center>
<form id = \"form1\" method = \"post\" action = \"viewhistorywebhost.php?webhost=$requestid\">
<input type = \"submit\" name = \"button\" id = \"button\" value = \"Details\" />
</form>
</center>";
echo "</tr>";
}
echo "</table>";
return $out;
}
}
}
这是表单和触发器
<form id = "form1" method = "post" action = "#">
<select id="select1" name="historyfilter">
<option value='' selected disabled>Select item type</option>
<?php
$options = array('approved' => 'Approved',
'cancelled'=>'Cancelled',
'rejected' => 'Rejected');
foreach($options as $value => $type){
echo "<option value=\"$value\">$type</option>";
}
?>
</select>
<input type = "submit" name = "button" id = "submit" value = "Go" />
</form>
<?php
$webhost=new requisition2();
echo $webhost->listhistoryHost();
?>