代码求简化

WBOY
Lepaskan: 2016-06-23 13:59:13
asal
890 orang telah melayarinya

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

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

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


回复讨论(解决方案)

查询那块写成函数不是更好点吗

$sql = "SELECT area, type, count(*) AS count FROM `khxx` WHERE dates>=‘$mindate’ and dates

$sql = "SELECT area, type, count(*) AS count FROM `khxx` WHERE dates>=‘$mindate’ and dates 主要是
我的table 是固定了 不知道怎么写在td中 如果没有就显示 0

想把相应的值 显示在固定了的表格中的单元格中

Label berkaitan:
sumber:php.cn
Kenyataan Laman Web ini
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Tutorial Popular
Lagi>
Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan