这是我写的计算发帖数的代码
$query_5=("select count(*) as total from lt_send where lt_send_small_type='".$_GET[$myrow_1['lt_small_type_content']]."'");
$result=mysql_query($query_5);
$message_count=mysql_result($result,0,"total");
<?php echo $message_count ;?>
为什么输出的数据不对呢
我要输出的是小类标题对应的帖子总数
$query_5=("select count(*) as total from lt_send where lt_send_small_type='".$_GET[$myrow_1['lt_small_type_content']]."'");
$result=mysql_query($query_5);
$message_count=mysql_result($result,0,"total");
<?php echo $message_count ;?>
为什么输出的数据不对呢
我要输出的是小类标题对应的帖子总数
解决方案 »
- PHP新手求教
- php session_start问题
- 求|PHP配置环境
- 在apache中配置PHP,作为Module和作为CGI Binary有什么不同?
- 网页编码的问题,想弄清楚峡它,希望高手指点!
- php页面中两个<select>,其中一个根据另一个的内容改变而改变。
- 那位大虾帮我看看,如果数据库连接成功是什么样子,连接不成功有是什么样子?连了N天了,预览啥也不显示?
- -------本周排行问题
- 【ThinkPHP】诡异的现象,$this->rowUser['ext'] = '';无法赋值!但是array_merge 却可以!
- 新人关于php与mariadb的查询问题
- session的一些问题
- php 缩略图 imagecreatefromstring
應該是$result = mysql_query($query_5);
$row = mysql_fetch_row($result);
$message_count = $row[0];
//或者
$sql = "select * from lt_send where lt_send_small_type='{$_GET[$myrow_1['lt_small_type_content']]}'";
$result = mysql_query($sql);
$message_count = mysql_num_rows($result);
$result=mysql_query($query_5);
$message_count=mysql_result($result,0,"total");
<?php echo $message_count ;?>在php标签中套php标签不会报错么?....................................
去掉标签,直接echo $message_count ;
<?php echo $message_count ;?>这句是后面才输出的,没在同一个PHP标签里面,他可以输出但是数据不对
$_GET[$myrow_1['lt_small_type_content']]把你传递到这个页面的链接代码写出来
想在首页显示发帖总数
<?php
session_start();
include("conn/conn.php");
$query=mysql_query("select * from lt_big_type");
while($myrow=mysql_fetch_array($query)){
$querys=mysql_query("select * from lt_small_type where lt_big_type_content='$myrow[lt_big_type_content]'");
$query_1=mysql_query("select * from lt_send where lt_send_type='1' and lt_send_small_type='".$_GET[content_1]."'");
$myrows=mysql_fetch_array($querys);
$sql = "select * from lt_send where lt_send_small_type='{$_GET[lt_small_type_content]}'";
echo $sql;
$result = mysql_query($sql);
$message_count = mysql_num_rows($result);
$query_6="select count(*) as total from lt_send where lt_send_small_type='$_GET[content_1]' and lt_send_type_hotspot=1";
$result1=mysql_query($query_6);
$message_count1=mysql_result($result1,0,"total");
?>
<table width="960" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#AFC7FC" class="k">
<tr class="l">
<td height="30" valign="middle" background="images/OOOPIC_ainibushi23tian_20090623180a81b92c32f0c5_conew1.jpg" class="d"(id_a<?php echo $myrow['lt_big_type_id'];?>)" > <img src="images/old.gif" width="23" height="26" /> <?php echo $myrow['lt_big_type_content'];?></a></td>
</tr>
<tr class="l">
<td (id_a<?php echo $myrow['lt_big_type_id'];?>)" ><?php
$query_1=mysql_query("select * from lt_small_type where lt_big_type_content='$myrow[lt_big_type_content]' ");
while($myrow_1=mysql_fetch_array($query_1)){
?>
<tr class="l">
<td height="23" colspan="2" align="left" valign="middle"><table width="1024" border="0">
<tr>
<td>
<table width="1024" border="0">
<tr>
<td width="135"><a href="in.php?content=<?php echo $myrow['lt_big_type_content'];?>&&content_1=<?php echo $myrow_1['lt_small_type_content'];?>" target=""><img src="images/0042.gif" /></a></td>
<td width="281"><p><a href="in.php?content=<?php echo $myrow['lt_big_type_content'];?>&&content_1=<?php echo $myrow_1['lt_small_type_content'];?>" target="" class="k"><?php echo $myrow_1['lt_small_type_content'];?></a></p>
<p>创建时间:<?php echo $myrow_1['lt_small_type_date'];?></p></td>
<td width="594"><table width="596" border="0">
<tr>
<td width="300" align="center" valign="top">发帖数</td>
<td width="286" align="center">热门帖数</td>
</tr>
<tr>
<td height="42" align="center"><?php
echo $message_count;
?></td>
<td align="center"><?php echo $message_count1;?></td>
</tr>
</table></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table></td>
</tr>
</table>
</td>
</tr>
<?php }?>
$sql = "select * from lt_send where lt_send_small_type='{$_GET[content_1}'";
echo $sql;
$result = mysql_query($sql);
$message_count = mysql_num_rows($result);
我想着是$sql那句没写对,因为输出$sql时他输出的是select * from lt_send where lt_send_small_type='' 好像where后面没有输出内容。想问你一下要怎么写,谢谢了
,