PHP代码:    <div class="list">
<?php
include("showMsgBoard.php");
?>
        <h3><span>People say</span></h3>
        <ul id="allList">
            <?php
for($i=0;$i<$num;$i++)

echo "<li><div class='userPic'><img src= "
.$img[$i]
. " /></div><div class='content'><div class='userName'><a href='javascript:;'>"
.$author[$i]
."</a>:</div><div class='msgInfo'>"
.$content[$i]
."</div><div class='times'><span>"
.$date[$i]
."</span><a class='del' href='javascript:;'>Remove</a></div></div></li>";
}
echo "<div style='text-align: center;'><a class='more' href='javascript:;' onclick='showMore();'>More</a></div>"
?>

        </ul>

    </div>
JS代码:
function showMore()
{
var listNum = document.getElementById("allList").getElementsByName("li").length;

doAjax('showMsgBoard.php?isMore='+'true' + '&listNum=' + listNum );

var img = "<? echo $img; ?>";
var author = "<? echo $author; ?>";
var date = "<? echo $date; ?>";
var content = "<? echo $content; ?>";
var num = "<? echo $num; ?>";
for(i=0;i<num;i++)
{
var oLi = document.createElement("li");
oLi.innerHTML = "<div class=\"userPic\"><img src=\"" + img[i] + "\"></div>\
 <div class=\"content\">\
 <div class=\"userName\"><a href=\"javascript:;\">" + author[i] + "</a>:</div>\
 <div class=\"msgInfo\">" + content[i].replace(/<[^>]*>|&nbsp;/ig, "") + "</div>\
 <div class=\"times\"><span>" + date[i] + "</span><a class=\"del\" href=\"javascript:;\">Remove</a></div>\
     </div>";
//插入元素
aLi.length ? oUl.insertBefore(oLi, aLi[0]) : oUl.appendChild(oLi);
}
}showMsgBoard.php:<?php
header('Content-Type:text/html;charset=GB2312');//避免输出中文乱码,linux下不需要
$con = @mysql_connect("localhost","root","root");
mysql_select_db("gimmiehelp", $con);
$isMore = @$_GET['isMore'];

if($isMore == "true") //判断是点击more进来的还是刷页面的时候进来的
{
$listNum = $_GET['listNum'];
$listHigh = $listNum + 20;

$sql="select comment_author, comment_author_img, comment_date_gmt, comment_content
  from gmh_messageboard_comments order by comment_date_gmt DESC limit "+ $listNum + ", " + $listHigh;
$result = mysql_query($sql, $con);

if(!$result)
{
$isMore = false;//如果数据库里没有记录了返回false
}
else
{
$isMore = true;

$img=array();
$author=array();
$date=array();
$content=array();

while ($row=mysql_fetch_array($result)) 
{
$img[]=$row['comment_author_img'];
$author[]=$row['comment_author'];
$date[]=$row['comment_date_gmt'];
$content[]=$row['comment_content'];
}

$num=count($img);
}
mysql_free_result($result);
}

else
{

$sql="select comment_author, comment_author_img, comment_date_gmt, comment_content
  from gmh_messageboard_comments order by comment_date_gmt DESC limit 5";
$result = mysql_query($sql, $con);

$img=array();
$author=array();
$date=array();
$content=array();

while ($row=mysql_fetch_array($result)) 
{
$img[]=$row['comment_author_img'];
$author[]=$row['comment_author'];
$date[]=$row['comment_date_gmt'];
$content[]=$row['comment_content'];
}

$num=count($img);

mysql_free_result($result);
}

mysql_close($con);
?>点了more没反应,也不知道啥毛病诶,大家给帮忙看看呗!PS:才接触PHP大家给推荐个什么开发工具能调试的吧。用DW都不知道错在哪里。蛋疼啊

解决方案 »

  1.   

    Firefox ->firebug;代码我就不看了,自己琢磨吧,我刚从Mysql的SQL缓过神来...正琢磨着要不要和东京热打个招呼...
      

  2.   


    Firebug我用来看html+css的,我想设断点跟进去看哪里错了额。
      

  3.   

      $sql="select comment_author, comment_author_img, comment_date_gmt, comment_content
                  from gmh_messageboard_comments order by comment_date_gmt DESC limit ". $listNum . ", " .$listHigh;另外楼主一步一步调试。不要急。
      

  4.   

    代碼就不看了,
    告訴你另外一個方法一開始就讀取20條數據,
    下面的15條用Div隱藏起來,點擊More的時候再顯示還不用再次操作數據庫
      

  5.   

    人肉断点,反正我在win下没设置成功过断点.eclipse.linux下倒是轻松解决了断点问题。
      

  6.   


    调试我ZEND导了一下午网站导不进去