首頁  >  文章  >  後端開發  >  代码求简单化

代码求简单化

WBOY
WBOY原創
2016-06-13 11:54:201060瀏覽

代码求简化

<br />	<form class="f"action="wel.php" method="get"><br />		<input class="inp" type="text" name="mindate" value="<?php echo $mindate ?>" onfocus="HS_setDate(this)" readonly="readonly"/>至<br />        <input class="inp" type="text" name="maxdate" value="<?php echo $maxdate ?>" onfocus="HS_setDate(this)" readonly="readonly"/><br />		<input class="sub" type="submit" value="统计"/><br />	</form><br />

<br /><?php<br />$sql="SELECT count(*) AS count FROM `khxx` WHERE dates>='".$mindate."' and dates<='".$maxdate."' and `type`='新增' and `area`='城南东'";<br />$cndx=mysql_result(mysql_query($sql),0);<br />$sql="SELECT count(*) AS count FROM `khxx` WHERE dates>='".$mindate."' and dates<='".$maxdate."' and `type`='续费' and `area`='城南东'";<br />$cndf=mysql_result(mysql_query($sql),0);<br />$sql="SELECT count(*) AS count FROM `khxx` WHERE dates>='".$mindate."' and dates<='".$maxdate."' and `type`='升兆' and `area`='城南东'";<br />$cnds=mysql_result(mysql_query($sql),0);<br />$sql="SELECT count(*) AS count FROM `khxx` WHERE dates>='".$mindate."' and dates<='".$maxdate."' and `type`='免费' and `area`='城南东'";<br />$cndm=mysql_result(mysql_query($sql),0);<br /><br />$sql="SELECT count(*) AS count FROM `khxx` WHERE dates>='".$mindate."' and dates<='".$maxdate."' and `type`='新增' and `area`='城南西'";<br />$cnxx=mysql_result(mysql_query($sql),0);<br />$sql="SELECT count(*) AS count FROM `khxx` WHERE dates>='".$mindate."' and dates<='".$maxdate."' and `type`='续费' and `area`='城南西'";<br />$cnxf=mysql_result(mysql_query($sql),0);<br />$sql="SELECT count(*) AS count FROM `khxx` WHERE dates>='".$mindate."' and dates<='".$maxdate."' and `type`='升兆' and `area`='城南西'";<br />$cnxs=mysql_result(mysql_query($sql),0);<br />$sql="SELECT count(*) AS count FROM `khxx` WHERE dates>='".$mindate."' and dates<='".$maxdate."' and `type`='免费' and `area`='城南西'";<br />$cnxm=mysql_result(mysql_query($sql),0);<br />

<br /> <tr><br />    <td>城南东</td><br />    <td><?php echo $cndx;?></td><br />    <td><?php echo $cndf;?></td><br />    <td><?php echo $cnds;?></td><br />    <td><?php echo $cndm;?></td><br />  </tr><br />  <tr><br />    <td>城南西</td><br />    <td><?php echo $cnxx;?></td><br />    <td><?php echo $cnxf;?></td><br />    <td><?php echo $cnxs;?></td><br />    <td><?php echo $cnxm;?></td><br />  </tr><br />

------解决方案--------------------
查询那块写成函数不是更好点吗
------解决方案--------------------
$sql = "SELECT area, type, count(*) AS count FROM `khxx` WHERE dates>=‘$mindate’ and dates

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn