21,891
社区成员
发帖
与我相关
我的任务
分享
<form action="data.php " method="get" name="form1" >
<p><input name="township" type="text" size="8"></p></th>
<p><input name="range" type="text" size="8"></p>
<p><input name="dir" type="text" size="8"></p>
<p><input name="section" type="text" size="8"></p>
<input type="submit" name="submit" value="Submit">
</form>
<?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 ORDER BY Township"; if (!empty($where)) { $query.=' WHERE '.$where; }
?>
$map=array('Township'=>'township','Range'=>'range', 'dirid'=>'dir', 'Section'=>'section');
$where='';
$and='';
$dir_array['1']=1;$dir_array['E']=1;$dir_array['2']=2;$dir_array['W']=2;
foreach ($map as $k => $v) {
if (!empty($_GET[$v])) {
$value =$_GET[$v];
if ($k=='dirid')$value=$dir_array[$value];
$where.=$and.$k.'='.$value;
$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 ORDER BY Township";
if (!empty($where)) {
$query.=' WHERE '.$where;
}