a.php
<form action="b.php " method="get" name="form2" >
<table>
<input name="township" type="text" size="8">
<input name="range" type="text" size="8">
<input name="dir" type="text" size="8">
<input name="section" type="text" size="8">
<input name="submit" type="submit" value="submit">
</table>
</form>
b.php
<?php
$map=array('Township'=>'township','Range'=>'range', 'dirid'=>'dir', 'Section'=>'section'); $where=''; $and=''; foreach ($map as $k => $v) { if (!empty($_GET[$v])) { $where.=$and.$k.'='.$_GET[$v]; $and=' and '; } } $query =" SELECT Business_Owner,Business_Name,Mailing_Address,Phone_Number,Crop_Type,Crop_Location,Section,Township,Range,Quarter,Acreage,County FROM pesticide_sensitive_crop"; if (!empty($where)) { $query.=' WHERE '.$where; }?> 如上代码,我想让从数据库中搜索出的数据按照数据库中的字段County, Township, Range升序排列, b.php中的代码应该怎么改啊,谢谢大家了。
<form action="b.php " method="get" name="form2" >
<table>
<input name="township" type="text" size="8">
<input name="range" type="text" size="8">
<input name="dir" type="text" size="8">
<input name="section" type="text" size="8">
<input name="submit" type="submit" value="submit">
</table>
</form>
b.php
<?php
$map=array('Township'=>'township','Range'=>'range', 'dirid'=>'dir', 'Section'=>'section'); $where=''; $and=''; foreach ($map as $k => $v) { if (!empty($_GET[$v])) { $where.=$and.$k.'='.$_GET[$v]; $and=' and '; } } $query =" SELECT Business_Owner,Business_Name,Mailing_Address,Phone_Number,Crop_Type,Crop_Location,Section,Township,Range,Quarter,Acreage,County FROM pesticide_sensitive_crop"; if (!empty($where)) { $query.=' WHERE '.$where; }?> 如上代码,我想让从数据库中搜索出的数据按照数据库中的字段County, Township, Range升序排列, b.php中的代码应该怎么改啊,谢谢大家了。
order by County,Township,Range就没问题了
1,10,11,12,13,14,15,16,17,18,2,21,22,23,24,25,26,27,28,29,3,
31,32,33,35,36,4,5,6,7,8急,有哪位帮帮我,多谢了