$pieces=explode("\n",$temp);
$size=count($pieces);
$S="";
for ($i=$star;$i<($num+$star);$i++) {
  if (eregi("",$pieces[$i]) and eregi("",$pieces[$i]) and ($Re==1)){ 
$headtemp_3=str_replace("","<b>",$pieces[$i]);
$headtemp_3=str_replace("","</b>",$headtemp_3);
$S.=$headtemp_3;
  }
  else {
$S.=$pieces[$i];
 }
}
echo "<SPAN><p>$S."</p></span>";
$temp是文章内容,$star是确定内容开头,$num是限定页面内容的长短,内容的限定是以回车为判断的
然后你就再调用一个函数,把内容,头,在大小限定好就ok了
如果那位有不是以回车,而是以字数判定就贡献出来吧!^_^

解决方案 »

  1.   

    phpArticle 有这功能。 他们是在输入时就做了准备。 一页显示多少。自己做主
      

  2.   

    for ($i=$star;$i<($num+$star);$i++) {
      if (eregi("",$pieces[$i]) and eregi("",$pieces[$i]) and ($Re==1)){ 
    $headtemp_3=str_replace("","<b>",$pieces[$i]);
    $headtemp_3=str_replace("","</b>",$headtemp_3);
    $S.=$headtemp_3;
      }
    谁能解释一下这段代码
      

  3.   

    /**+-----------------------------------------------
    | 取得最末页.$link为1是为带链接
    | i.e. $pb         = new PageBar(50, 10);
    |  $total_page = $pb->total_page(1);
    |  +-----------------------------------------------
    */
    function total_page($link='') {
    $linkhead  = $this->linkhead;
    $total_page = $this->total_page;
    if ($link==1) {
    return "<a href=\"$linkhead"."pagecount=$total_page\" title=\"The lasted page\">[$total_page]</a>";
    }else {
    return $total_page;
    }
    }
    #End of function total_page();
    /**+-----------------------------------------------
    | 取得上一页.$char为链接的字符,默认为"[<]"
    | i.e. $pb       = new PageBar(50, 10);
    |  $pre_page = $pb->pre_page("上一页");
    |  +-----------------------------------------------
    */
    function pre_page($char='') {
    $linkhead  = $this->linkhead;
    $pagecount = $this->pagecount;
    if (empty($char)) {
    $char = "[<]";
    }
    if ($pagecount>1) {
    $pre_page = $pagecount - 1;
    return "<a href=\"$linkhead"."pagecount=$pre_page\" title=\"previous page\">$char</a>";
    } else {
    return '';
    }
    }
    #End of function pre_page();
    /**+-----------------------------------------------
    | 取得下一页.$char为链接的字符,默认为"[>]"
    | i.e. $pb        = new PageBar(50, 10);
    |  $next_page = $pb->next_page("下一页");
    |  +-----------------------------------------------
    */
    function next_page($char='') {
    $linkhead   = $this->linkhead;
    $total_page = $this->total_page;
    $pagecount  = $this->pagecount;
    if (empty($char)) {
    $char = "[>]";
    }
    if ($pagecount<$total_page) {
    $next_page = $pagecount + 1;
    return "<a href=\"$linkhead"."pagecount=$next_page\" title=\"next page\">$char</a>";
    } else {
    return '';
    }
    }
    #End of function next_page();
    /**+-----------------------------------------------
    | 取得页码数字条.  $num 为个数,默认为10
    |                    $color 为当前链接的突显颜色
    |  $left 数字左边 默认为"[" 
    |                    $right 数字左右 默认为"]"
    | i.e. $pb      = new PageBar(50, 10);
    |  $num_bar = $pb->num_bar(9, "$cccccc");
    |  +-----------------------------------------------
    */
    function num_bar($num='', $color='', $left='', $right='') {
    $num       = (empty($num))?10:$num;
    $this->num = $num;
    $mid       = floor($num/2);
    $last      = $num - 1; 
    $pagecount = $this->pagecount;
    $totalpage = $this->total_page;
    $linkhead  = $this->linkhead;
    $left      = (empty($left))?"[":$left;
    $right     = (empty($right))?"]":$right;
    $color     = (empty($color))?"#ff0000":$color;
    $minpage   = (($pagecount-$mid)<1)?1:($pagecount-$mid);
    $maxpage   = $minpage + $last;
    if ($maxpage>$totalpage) {
    $maxpage = $totalpage;
    $minpage = $maxpage - $last;
    $minpage = ($minpage<1)?1:$minpage;
    }
    for ($i=$minpage; $i<=$maxpage; $i++) {
    $char = $left.$i.$right;
    if ($i==$pagecount) {
    $char = "<font color='$color'>$char</font>";
    }
    $linkchar = "<a href='$linkhead"."pagecount=$i'>".$char."</a>";
    $linkbar  = $linkbar.$linkchar;
    } return $linkbar;
    }
    #End of function num_bar();
    /**+-----------------------------------------------
    | 取得上一组数字条.$char为链接的字符,默认为"[<<]"
    | i.e. $pb        = new PageBar(50, 10);
    |        $num_bar   = $pb->num_bar();
    |  $pre_group = $pb->pre_group();
    |  +-----------------------------------------------
    */
    function pre_group($char='') {
    $pagecount   = $this->pagecount;
    $linkhead    = $this->linkhead;
    $num      = $this->num;
    $mid         = floor($num/2);
    $minpage     = (($pagecount-$mid)<1)?1:($pagecount-$mid);
    $char        = (empty($char))?"[<<]":$char;
    $pgpagecount = ($minpage>$num)?$minpage-$mid:1;
    return "<a href='$linkhead"."pagecount=$pgpagecount' title=\"previous group number bar\">".$char."</a>";
    }
    #End of function pre_group();

    /**+-----------------------------------------------
    | 取得下一组数字条.$char为链接的字符,默认为"[>>]"
    | i.e. $pb         = new PageBar(50, 10);
    |        $num_bar    = $pb->num_bar();
    |  $next_group = $pb->next_group();
    |  +-----------------------------------------------
    */
    function next_group($char='') {
    $pagecount = $this->pagecount;
    $linkhead  = $this->linkhead;
    $totalpage = $this->total_page;
    $num    = $this->num;
    $mid       = floor($num/2);
    $last      = $num; 
    $minpage   = (($pagecount-$mid)<1)?1:($pagecount-$mid);
    $maxpage   = $minpage + $last;
    if ($maxpage>$totalpage) {
    $maxpage = $totalpage;
    $minpage = $maxpage - $last;
    $minpage = ($minpage<1)?1:$minpage;
    } $char = (empty($char))?"[>>]":$char;
    $ngpagecount = ($totalpage>$maxpage+$last)?$maxpage + $mid:$totalpage; return "<a href='$linkhead"."pagecount=$ngpagecount' title=\"next group number bar\">".$char."</a>";
    }
    #End of function next_group(); /**+-----------------------------------------------
    | 取得整个数字条,上一页,下一页,上一组
    |   下一组的等.$num数字个数,$color 当前链接的突显色
    | i.e. $pb               = new PageBar(50, 10);
    |        $whole_num_bar    = $pb->whole_num_bar(9);
    |  +-----------------------------------------------
    */
        function whole_num_bar($num='', $color='') {
        $num_bar = $this->num_bar($num, $color);
    return  $this->first_page(1).$this->pre_group().$this->pre_page().$num_bar.$this->next_page().$this->next_group().$this->total_page(1);
        }
    #End of function whole_bar();
    /**+-----------------------------------------------
    | 取得整链接,等于whole_num_bar加上表单跳转.
    |   $num数字个数,$color 当前链接的突显色
    | i.e. $pb           = new PageBar(50, 10);
    |        $whole_bar    = $pb->whole_bar(9);
    |  +-----------------------------------------------
    */
    function whole_bar($jump='', $num='', $color='') {
    $whole_num_bar = $this->whole_num_bar($num, $color)."&nbsp;";
    $jump_form     = $this->jump_form($jump);
    return <<<EOT
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr> 
        <td align="right">$whole_num_bar</td>
        <td width="50" align="right">$jump_form</td>
      </tr>
    </table>
    EOT;
    }
    /**+-----------------------------------------------
    | 跳转表单
    |   i.e. $pb           = new PageBar(50, 10);
    |        $Jump_form    = $pb->Jump_form();
    |  +-----------------------------------------------
    */
    function Jump_form($jump='') {
    $formname = "pagebarjumpform".$jump;
    $jumpname = "jump".$jump; 
    $linkhead = $this->linkhead;
    $total   = $this->total_page;
    $form = <<<EOT
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <script language="javascript">
    function $jumpname(linkhead, total, page){

    var pagecount = (page.value>total)?total:page.value;
    pagecount = (pagecount<1)?1:pagecount;
    location.href = linkhead + "pagecount=" + pagecount;
    return false;
    }
    </script>
           <form name="$formname" method="post" onSubmit="return $jumpname('$linkhead', $total, $formname.page)"><tr>
              <td>
            <input name="page" type="text" size="1">
    <input type="button" name="Submit" value="GO" onClick="return $jumpname('$linkhead', $total, $formname.page)">
          </td>
            </tr></form></table>
    EOT;
    return $form;
    }
    #End of function Jump_form();
    }
    #End of class PageBar;
    /*****//example
    $total = 1000;
    $onepage = 20;
    $pb       = new PageBar($total, $onepage);
    $offset   = "offset=".$pb->offset();
    $pagebar1  = $pb->whole_bar();
    $pagebar2  = $pb->whole_bar(2);
    echo $offset."<br>".$pagebar1."<br>";
    echo $offset."<br>".$pagebar1."<br>";
    /** return:
       offset=0
    [1][<<][1][2][3][4][5][6][7][8][9][10][>][>>][50]        
    *****/
    ?>
      

  4.   

    for ($i=$star;$i<($num+$star);$i++) {
      if (eregi("",$pieces[$i]) and eregi("",$pieces[$i]) and ($Re==1)){ 
    $headtemp_3=str_replace("","<b>",$pieces[$i]);
    $headtemp_3=str_replace("","</b>",$headtemp_3);
    $S.=$headtemp_3;
      }
    谁能解释一下这段代码
      

  5.   

    这段代码只是将指定行数的内容块中的和标记替换为<b>和</b>
    如果$star为0,也就是说从一行开始替换,替换的行数为$num+$star,
    先判断第一行中是否存在和,如果存在则替换.
    以此类推
      

  6.   

    <table border>
    <tr>
    <td>
    <span ID=oDiv1 STYLE="height=100; 
        width:90pt; text-align:left; font-size:9pt">
    </span>
    </td>
    <td>
    <span ID=oDiv2 STYLE="height=100; 
        width:90pt; text-align:left; font-size:9pt">
    </span>
    </td>
    </tr>
    </table><script>
    var s= "我现在数据库里面有一篇<b>很长</b>的文章,我要把他读出来显示在页面上,但是一个页面显示太难看了,所以想分页显示,不知道要怎么做,偶比较菜,麻烦哪位好心人告诉我,尽量说得简单一点,我怕我看不懂。哈哈<br>";
    s += "这个问题用js解决较好。可以这样写,自己扩展一下吧";
    var hh = oDiv1.offsetHeight;
    for(i=0;i<s.length;i++) {
      oDiv1.innerHTML = s.substr(0,i);
      if(hh < oDiv1.scrollHeight) {
        do {
          oDiv1.innerHTML = s.substr(0,--i);
        }while(hh < oDiv1.scrollHeight);
        break;
      }
    }
    oDiv2.innerHTML = s.substr(i);
    </script>