<?php[
// 获取select值
$select_value = isset($_GET['select']) ? $_GET['select'] : '';
//echo $select_value;
//执行查询SQL
if($select_value==""){
_page("SELECT o_id FROM t_order",5);
$_result= mysql_query("SELECT * FROM t_order ORDER BY createtime DESC LIMIT $_pagenum,$_pagesize");
}
if($select_value=="option1"){
_page("SELECT o_id FROM t_order where status=0",4);
$_result1= mysql_query("SELECT * FROM t_order where status=0 ORDER BY createtime DESC LIMIT $_pagenum,$_pagesize");
//echo _num_rows($_result);
}
if($select_value=="option2"){
_page("SELECT o_id FROM t_order where status=1",20);
$_result= mysql_query("SELECT * FROM t_order where status=1 ORDER BY createtime DESC LIMIT $_pagenum,$_pagesize");
}
if($select_value=="option3"){
_page("SELECT o_id FROM t_order where status=2",20);
$_result= mysql_query("SELECT * FROM t_order where status=2 ORDER BY createtime DESC LIMIT $_pagenum,$_pagesize");
}[code=php]
<form action='order.php' style="margin-left:20px;">
<select name="select">
<option value="">全部状态</option>
<option value="option1" <?php
// 如果在上面获取的值和这个option里的值一样,
// 就打印selected,让这个option默认被选中
echo $select_value == 'option1' ? 'selected' : ''
?>>未付款</option>
<option value="option2" <?php
echo $select_value == 'option2' ? 'selected' : ''
?>>已付款待取件</option>
<option value="option3" <?php
echo $select_value == 'option3' ? 'selected' : ''
?>>已取件待送洗</option>
</select>
<input type="submit" value="查询" />
</form>
------解决思路----------------------
所有 '.php?page='
都改为 '.php?select=' . $select .'&page='
------解决思路----------------------
把你搜索的字段内容也传过去