代码求简单化

WBOY
WBOYoriginal
2016-06-13 11:54:201069parcourir

代码求简化

<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

Déclaration:
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn