这是论坛中的我的帖子的代码
<?php session_start();include("conn/conn.php"); if ($_GET['page']=="") {$_GET['page']=1;};if ($_GET[link_type]=="") {$_GET[link_type]=0;};?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<style type="text/css">
<!--
body {
background-color: #FFFFFF;
}
.STYLE5 {font-size: 12px}
body,td,th {
font-size: 12px;
}
.STYLE6 {font-size: 16px}
.STYLE8 {font-size: 14}
.STYLE9 {font-size: 14px}
-->
</style>
<title>我的帖子</title>
</head>
<body>
<table width="950" border="0" align="center" cellpadding="0" cellspacing="0"> <tr>
<td colspan="2" align="left"><img src="images/我的帖子.jpg" width="137" height="30"></td>
<td width="178"> </td>
<td width="172"> </td>
<td width="175"> </td>
</tr>
<tr>
<td width="216" height="40" align="center" bgcolor="#F7F7FF"><span class="STYLE5"></span></td>
<td width="209" bgcolor="#F7F7FF"><span class="STYLE5">标题</span></td>
<td width="178" bgcolor="#F7F7FF"><span class="STYLE5">创建时间</span></td>
<td width="172" bgcolor="#F7F7FF"><span class="STYLE5">创建人</span></td>
<td width="175" bgcolor="#F7F7FF"><span class="STYLE5">回复次数</span></td>
</tr>
<?php
if($_GET['page']){
$page_size=1;
$query="select count(*) as total from lt_send where lt_send_user='$_GET[my_forum_user]'";
$result=mysql_query($query);
$message_count=mysql_result($result,0,"total");
$page_count=ceil($message_count/$page_size);
$offset=($_GET['page']-1)*$page_size;
$query_2=mysql_query("select * from lt_send where lt_send_user='$_GET[my_forum_user]' limit $offset, $page_size");
while($myrow_2=mysql_fetch_array($query_2)){
?>
<tr>
<td width="216" height="48" align="center" bgcolor="#F7F7FF"><img src="<?php echo $myrow_2[lt_send_picture];?>" /></td>
<td bgcolor="#F7F7FF"><a href="send_for_content.php?send_big_type=<?php echo $_GET[content];?>&&send_small_type=<?php echo $myrow_2[lt_send_small_type];?>&&send_id=<?php echo $myrow_2[lt_send_id];?>" target="_blank"><?php echo $myrow_2[lt_send_subject];?></a></td>
<td width="178" bgcolor="#F7F7FF"><?php echo $myrow_2[lt_send_date];?></td>
<td width="172" bgcolor="#F7F7FF"><?php echo $myrow_2[lt_send_user];?></td>
<td width="175" align="left" bgcolor="#F7F7FF"> <?php $query_s=mysql_query("select * from lt_reply where lt_send_id='$myrow_2[lt_send_id]'");
echo mysql_num_rows($query_s);
?></td>
</tr>
<?php }}?>
</table>
<table width="950" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#F7F7FF">
<tr>
<td width="573" height="41"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="197" height="31" align="center"><span class="STYLE5"><span class="STYLE8"><span class="STYLE9">帖子统计:</span><?php echo $message_count;?><span class="STYLE9"> 条</span></span><span class="STYLE9"> </span> </span></td>
<td width="189" align="center"><span class="STYLE5"> <span class="STYLE9">分页:</span>
<?php
$next=$_GET[link_type]*10;
$n=$_GET[link_type]-1;
$m=$_GET[link_type]+1;
$prev_page=$_GET['page']-10;
if ($_GET[link_type]==0){
echo "<img src=\"images/02.jpg\" width=\"8\" height=\"9\" border=\"0\" title=\"首页\">";
}else
{
echo "<a href='my_forum.php?vv=0&link_type=0&page=1&&my_forum_user=$_GET[my_forum_user]'><img src=\"images/02.jpg\" width=\"8\" border=\"0\" height=\"9\" border=\"0\" title=\"首页\"></a> ";
$ccc=$vv-10;
echo "<a href='my_forum.php?vv=$ccc&link_type=$n&page=$prev_page&&my_forum_user=$_GET[my_forum_user]'><img src=\"images/01.jpg\" width=\"8\" height=\"9\" border=\"0\" title=\"上十页\"></a>";
}?>
<?php
for ($j=1;$j<=$page_count;$j++) {
$pnext=$next+$j;
if ($mm==10){
break;
}
if ($mm>$page_count){
break;
}
if ($page_count-$vv<10){
if ($mm>=$page_count-$vv){
break;
}
}
?>
<?php
echo "<a href='my_forum.php?vv=$vv&link_type=$_GET[link_type]&page=$pnext&&my_forum_user=$_GET[my_forum_user]'> $pnext </a>";
$mm=$mm+1;
}
?>
</span></td>
<td width="201" align="center">
<span class="STYLE5">
<?php
$vv=$vv+$mm;
if ($page_count-$vv<=0){
echo "<img src=\"images/03.jpg\" width=\"8\" height=\"9\" border=\"0\" title=\"尾页\">";
}else{
echo "<a href='my_forum.php?vv=$vv&link_type=$m&page=$pnext&&my_forum_user=$_GET[my_forum_user]'><img src=\"images/03.jpg\" width=\"8\" height=\"9\" border=\"0\" title=\"下十页\"></a>";
}
if ($message_count==0){
echo "没有记录!"; }
?>
</span> </td>
</tr>
</table>
</td>
<td align="center"><span class="STYLE9"> <a href="send_for.php" target="_blank" class="STYLE6">我要发帖</a></span></td>
</tr></table>
<table width="950" height="119" border="0" align="center" cellpadding="0" cellspacing="0">
</table>
</body>
</html>
运行之后标题还有创建人没法显示,改了好久也没显示。求高手帮忙
<?php session_start();include("conn/conn.php"); if ($_GET['page']=="") {$_GET['page']=1;};if ($_GET[link_type]=="") {$_GET[link_type]=0;};?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<style type="text/css">
<!--
body {
background-color: #FFFFFF;
}
.STYLE5 {font-size: 12px}
body,td,th {
font-size: 12px;
}
.STYLE6 {font-size: 16px}
.STYLE8 {font-size: 14}
.STYLE9 {font-size: 14px}
-->
</style>
<title>我的帖子</title>
</head>
<body>
<table width="950" border="0" align="center" cellpadding="0" cellspacing="0"> <tr>
<td colspan="2" align="left"><img src="images/我的帖子.jpg" width="137" height="30"></td>
<td width="178"> </td>
<td width="172"> </td>
<td width="175"> </td>
</tr>
<tr>
<td width="216" height="40" align="center" bgcolor="#F7F7FF"><span class="STYLE5"></span></td>
<td width="209" bgcolor="#F7F7FF"><span class="STYLE5">标题</span></td>
<td width="178" bgcolor="#F7F7FF"><span class="STYLE5">创建时间</span></td>
<td width="172" bgcolor="#F7F7FF"><span class="STYLE5">创建人</span></td>
<td width="175" bgcolor="#F7F7FF"><span class="STYLE5">回复次数</span></td>
</tr>
<?php
if($_GET['page']){
$page_size=1;
$query="select count(*) as total from lt_send where lt_send_user='$_GET[my_forum_user]'";
$result=mysql_query($query);
$message_count=mysql_result($result,0,"total");
$page_count=ceil($message_count/$page_size);
$offset=($_GET['page']-1)*$page_size;
$query_2=mysql_query("select * from lt_send where lt_send_user='$_GET[my_forum_user]' limit $offset, $page_size");
while($myrow_2=mysql_fetch_array($query_2)){
?>
<tr>
<td width="216" height="48" align="center" bgcolor="#F7F7FF"><img src="<?php echo $myrow_2[lt_send_picture];?>" /></td>
<td bgcolor="#F7F7FF"><a href="send_for_content.php?send_big_type=<?php echo $_GET[content];?>&&send_small_type=<?php echo $myrow_2[lt_send_small_type];?>&&send_id=<?php echo $myrow_2[lt_send_id];?>" target="_blank"><?php echo $myrow_2[lt_send_subject];?></a></td>
<td width="178" bgcolor="#F7F7FF"><?php echo $myrow_2[lt_send_date];?></td>
<td width="172" bgcolor="#F7F7FF"><?php echo $myrow_2[lt_send_user];?></td>
<td width="175" align="left" bgcolor="#F7F7FF"> <?php $query_s=mysql_query("select * from lt_reply where lt_send_id='$myrow_2[lt_send_id]'");
echo mysql_num_rows($query_s);
?></td>
</tr>
<?php }}?>
</table>
<table width="950" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#F7F7FF">
<tr>
<td width="573" height="41"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="197" height="31" align="center"><span class="STYLE5"><span class="STYLE8"><span class="STYLE9">帖子统计:</span><?php echo $message_count;?><span class="STYLE9"> 条</span></span><span class="STYLE9"> </span> </span></td>
<td width="189" align="center"><span class="STYLE5"> <span class="STYLE9">分页:</span>
<?php
$next=$_GET[link_type]*10;
$n=$_GET[link_type]-1;
$m=$_GET[link_type]+1;
$prev_page=$_GET['page']-10;
if ($_GET[link_type]==0){
echo "<img src=\"images/02.jpg\" width=\"8\" height=\"9\" border=\"0\" title=\"首页\">";
}else
{
echo "<a href='my_forum.php?vv=0&link_type=0&page=1&&my_forum_user=$_GET[my_forum_user]'><img src=\"images/02.jpg\" width=\"8\" border=\"0\" height=\"9\" border=\"0\" title=\"首页\"></a> ";
$ccc=$vv-10;
echo "<a href='my_forum.php?vv=$ccc&link_type=$n&page=$prev_page&&my_forum_user=$_GET[my_forum_user]'><img src=\"images/01.jpg\" width=\"8\" height=\"9\" border=\"0\" title=\"上十页\"></a>";
}?>
<?php
for ($j=1;$j<=$page_count;$j++) {
$pnext=$next+$j;
if ($mm==10){
break;
}
if ($mm>$page_count){
break;
}
if ($page_count-$vv<10){
if ($mm>=$page_count-$vv){
break;
}
}
?>
<?php
echo "<a href='my_forum.php?vv=$vv&link_type=$_GET[link_type]&page=$pnext&&my_forum_user=$_GET[my_forum_user]'> $pnext </a>";
$mm=$mm+1;
}
?>
</span></td>
<td width="201" align="center">
<span class="STYLE5">
<?php
$vv=$vv+$mm;
if ($page_count-$vv<=0){
echo "<img src=\"images/03.jpg\" width=\"8\" height=\"9\" border=\"0\" title=\"尾页\">";
}else{
echo "<a href='my_forum.php?vv=$vv&link_type=$m&page=$pnext&&my_forum_user=$_GET[my_forum_user]'><img src=\"images/03.jpg\" width=\"8\" height=\"9\" border=\"0\" title=\"下十页\"></a>";
}
if ($message_count==0){
echo "没有记录!"; }
?>
</span> </td>
</tr>
</table>
</td>
<td align="center"><span class="STYLE9"> <a href="send_for.php" target="_blank" class="STYLE6">我要发帖</a></span></td>
</tr></table>
<table width="950" height="119" border="0" align="center" cellpadding="0" cellspacing="0">
</table>
</body>
</html>
运行之后标题还有创建人没法显示,改了好久也没显示。求高手帮忙
先print_r($myrow_2);看是否也是空值.
另外,这句话
<td bgcolor="#F7F7FF"><a href="send_for_content.php?send_big_type=<?php echo $_GET[content];?>&&send_small_type=<?php echo $myrow_2[lt_send_small_type];?>&&send_id=<?php echo $myrow_2[lt_send_id];?>" target="_blank"><?php echo $myrow_2[lt_send_subject];?></a></td>参数连接符号是一个&,也就是&所以你的红色部分多了一个。
删了&也没变化啊,还是不能
print_r($myrow_2);
看看读取出来的是否有对应标题和创建人的值。如果没相应值,那就不是代码错误。
如果有值,说明下面有错误,才可以继续判断是什么问题。
Array ( [0] => 1 [lt_send_id] => 1 [1] => 0 [lt_send_end] => 0 [2] => [lt_send_user] => [3] => [lt_send_subject] => [4] => [lt_send_content] => [5] => [lt_send_accessories] => [6] => 2011-10-12 06:04:52 [lt_send_date] => 2011-10-12 06:04:52 [7] => [lt_send_picture] => [8] => [lt_send_small_type] => [9] => 0 [lt_send_type] => 0 [10] => [lt_send_type_distillate] => [11] => [lt_send_type_hotspot] => [12] => 0 [lt_send_types] => 0 ) ;看到了么?数据库中读出来的标题和创建人都是空的。显示出来怎么能不是空的呢?
你给出的查询结果是没有值的。
可能的原因有:
1。查询语句写错了,你可以echo $sql ;看下是否是期望的sql语句。
2。你发帖那块的代码出错了,导致数据没有插入数据库。先检查1吧,用图形界面或命令行登录数据库看下数据库中是否有相应的值。
那就是你这块的查询语句错误了呗。
echo $sql ,看下是否正确,是什么结果