分情况查询

<?php
include ("../../include/common.inc.php");
header("Content-Type: text/html;charset=GBK");



$sheng = $_POST['sheng'];
$shi = $_POST['shi'];
$qu = $_POST['qu'];
$leixing=$_POST['leixing'];
$area=$_POST['area'];
$year=$_POST['year'];
$shi_index=$_POST['shi_index'];//市的索引,从0开始
$qu_index=$_POST['qu_index'];//区的索引,从0开始
if ($sheng==null or $shi==null or $qu==null or $leixing==null or $area==null or $year==null){
    echo "<script>alert('请确认您提交的数据是否完整')</script>"; 
    exit;
}



    //开始计算
  //查询省市区
$qu_sql="select * from price where sheng = '".$sheng."' and shi= '".$shi."' and qu='".$qu."' order by dates desc limit 1 "; $qu_result = mysql_query($qu_sql); while($qu_row = mysql_fetch_array($qu_result)){ $qu_result = $qu_row['price']; $total = ($qu_result-($qu_result*0.01*$shi_index)-($qu_result*0.001*$qu_index)-($qu_result*0.001*$leixing))*$area*$year; echo "<script>alert('".$total."(亩/元)')</script>"; if($qu_result != null){exit;} }
  //查询省市
if($GLOBALS['qu_result']==null){ $shi_sql=" select * from price where sheng = '".$sheng."' and shi= '".$shi."' order by dates desc limit 1 "; $shi_result = mysql_query($shi_sql); while($shi_row = mysql_fetch_array($shi_result)){ $shi_result = $shi_row['price']; $total = ($shi_result-($shi_result*0.01*$shi_index)-($shi_result*0.001*$qu_index)-($shi_result*0.001*$leixing))*$area*$year; echo "<script>alert('".$total."(亩/元)')</script>"; if($shi_result != null){exit;} } } //查询省 if($GLOBALS['shi_result']==null){ $sheng_sql=" select * from price where sheng = '".$sheng."' order by dates limit 1 "; $sheng_result = mysql_query($sheng_sql); while($sheng_row = mysql_fetch_array($sheng_result)){ $sheng_result = $sheng_row['price']; $total = ($sheng_result-($sheng_result*0.01*$shi_index)-($sheng_result*0.001*$qu_index)-($sheng_result*0.001*$leixing))*$area*$year; echo "<script>alert('".$total."(亩/元)')</script>"; if($sheng_result != null){exit;}else{} } } if($GLOBALS['sheng_result']){echo "<script>alert('未查询到相关的记录')</script>";} ?>

 

posted @ 2015-08-10 15:23  fleam  阅读(212)  评论(0编辑  收藏  举报