溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

php分頁常用方法兩種舉例.

發(fā)布時間:2020-09-20 09:50:44 來源:網(wǎng)絡(luò) 閱讀:466 作者:woshiyipizhu 欄目:web開發(fā)

1.php超長文本分頁.運用自定義函數(shù)unhtml


代碼:

<?php 

if ($page=="") {$page=1;}; //判斷變量的值是否為空

include("function.php"); //調(diào)用指定的包含文件,即自定義函數(shù)

?>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

<title>codego.net</title>

</head>

<body>

<table width="750" height="174" border="0" align="center" cellpadding="0" cellspacing="0">

  <tr>

    <td width="35" align="center">&nbsp;</td>

    <td width="100%" height="27" align="center"><strong>codego.net</strong></td>

    <td width="35" align="center">&nbsp;</td>

  </tr>

  <tr>

    <td align="left" valign="middle">&nbsp;</td>

    <td height="60" align="left" valign="middle"><table width="100%" height="50" border="0" cellpadding="0" cellspacing="0">

      <tr>

        <td bgcolor="#FFFFFF">

<?php   


  if($page){

$counter=file_get_contents("file/file.txt");

     $length=strlen(unhtml($counter));

     $page_count=ceil($length/1050);

 

     $c=msubstr($counter,0,($page-1)*1050);

     $c1=msubstr($counter,0,$page*1050);

echo substr($c1,strlen($c),strlen($c1)-strlen($c)); 

  }?>

    </td>

      </tr>

    </table></td>

    <td align="left" valign="middle">&nbsp;</td>

  </tr>

</table>

<table width="680" border="0" align="center" cellpadding="0" cellspacing="0">

  <tr>

    <td width="42%" align="center" valign="middle" bgcolor="#FFFFFF"><span class="STYLE1">&nbsp;&nbsp;頁次:<?php echo $page;?> / <?php echo $page_count;?> 頁 </span></td>

    <td width="58%" height="28" align="left" valign="middle" bgcolor="#FFFFFF"><span class="STYLE1"> &nbsp;分頁:

             <?php

   if($page!=1){   

    echo  "<a href=index.php?lmbs=codego.net&page=1>首頁</a>&nbsp;";

echo "<a href=index.php?lmbs=codego.net&page=".($page-1).">上一頁</a>&nbsp;";

  }

 if($page<$page_count){

       echo "<a href=index.php?lmbs=codego.net&page=".($page+1).">下一頁</a>&nbsp;";

       echo  "<a href=index.php?lmbs=codego.net&page=".$page_count.">尾頁</a>";

  }   

 ?>     

    </span> </td>

  </tr>

</table>

</body>

</html>

__________________________________________________________________________________________

2.Ajax無刷新分頁

代碼:

<?php if ($page=="") {$page=1;};   include("function.php");?>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

<title>codego.net</title>

<style type="text/css">

<!--

body,td,th {

font-size: 14px;

color: #000000;

}

-->

</style></head>

<script type="text/javascript" src="js/discuss_js.js"></script>

<body>

<table width="800" border="0" cellspacing="0" cellpadding="0">

  <tr>

    <td width="360"><table width="350" height="300" border="0" align="center" cellpadding="0" cellspacing="0">

    <tr>

 

    <td width="70" bgcolor="#C0C0C0"><div align="right">

      <input type="button" onClick="javascript:document.rp1.setfullscreen()" class="buttoncss" value="全屏播放"></div></td>

    <td width="70" bgcolor="#C0C0C0"><input name="button" type="button" class="buttoncss" onClick="javascript:window.close()" value="關(guān)閉視窗"></td>

    </tr>

  <tr>

    <td height="300" colspan="4" bgcolor="#ffffff"><div align="center"> 

<object onerror=alert("你的電腦中沒有安裝Realplayer播放器,請先安裝!") classid="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" name="rp1" width="350" height="300" id="rp1">

            <param name="_extentx" value="12000">

            <param name="_extenty" value="7500">

            <param name="shuffle" value="0">

            <param name="nolabels" value="0">

            <param name="autostart" value="-1">

            <param name="prefetch" value="0">

            <param name="controls" value="p_w_picpathwindow">

            <param name="console" value="clip1">

            <param name="loop" value="0">

            <param name="numloop" value="0">

            <param name="center" value="0">

            <param name="maintainaspect" value="0">

            <param name="backgroundcolor" value="#000000">

            <param name="src" value="rtsp://192.168.1.59/MR/21/sss.avi">

        </object>

        </div></td>

  </tr>

      <tr>

        <td height="60" colspan="2" bgcolor="#000000"><div align="center">

            <object classid="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" name="rp2" width="350" height="60" id="rp2">

              <param name="_extentx" value="12000">

              <param name="_extenty" value="1500">

              <param name="shuffle" value="0">

              <param name="nolabels" value="0">

              <param name="autostart" value="-1">

              <param name="prefetch" value="0">

              <param name="controls" value="controlpanel,statusbar">

              <param name="console" value="clip1">

              <param name="loop" value="0">

              <param name="numloop" value="0">

              <param name="center" value="0">

              <param name="maintainaspect" value="0">

              <param name="backgroundcolor" value="#000000">

            </object>

        </div></td>

      </tr>

</table></td>

    <td width="440" align="center" valign="top">


<div id="synopsis"><!--創(chuàng)建div標簽,用于獲取js文件中返回的分頁結(jié)果-->

<table width="425" border="0" cellspacing="0" cellpadding="0">

      <tr>

        <td height="20">&nbsp;</td>

      </tr>

      <tr>

        <td>

<?php

//讀取超長文本中的數(shù)據(jù),實現(xiàn)超長文本中數(shù)據(jù)的分頁顯示

  if($page){

$counter=file_get_contents("file/mr_synopsis.txt");

     $length=strlen($counter);

     $page_count=ceil($length/950);

     $c=msubstr($counter,0,($page-1)*950);

     $c1=msubstr($counter,0,$page*950);

echo substr($c1,strlen($c),strlen($c1)-strlen($c)); 

  }

?>    </td>

      </tr>

      <tr>

        <td>

<table border="0" align="center" cellpadding="0" cellspacing="0">

  <tr><!--設(shè)置超長文本分頁顯示的超級連接-->

    <td width="42%" align="center" valign="middle" bgcolor="#FFFFFF"><span class="STYLE1">&nbsp;&nbsp;頁次:<?php echo $page;?> / <?php echo $page_count;?> 頁 </span></td>

    <td width="58%" height="28" align="left" valign="middle" bgcolor="#FFFFFF"><span class="STYLE1"> &nbsp;分頁:

              <?php

   if($page!=1){  

?> 

<!--調(diào)用artpagination函數(shù),實現(xiàn)無刷新的分頁輸出-->

<a href="#" artpagination("mr_synopsis_ok.php?page=1")'>首頁</a>&nbsp;


<a href="#" artpagination("mr_synopsis_ok.php?&page=<?php echo $page-1;?>")'>上一頁</a>&nbsp;

<?php  }

 if($page<$page_count){

?>

<a href="#" artpagination("mr_synopsis_ok.php?page=<?php echo $page+1;?>")'>下一頁</a>&nbsp;

       <a href="#" artpagination("mr_synopsis_ok.php?page=<?php echo $page_count;?>")'>尾頁</a>

<?php

  }   

 ?>     

    </span> </td>

  </tr>

</table></td>

      </tr>

    </table>

</div>

</td>

  </tr>

</table>

</body>

</html>


向AI問一下細節(jié)

免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI