国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

? ??? ?? PHP ???? php+mysql分頁(yè)類

php+mysql分頁(yè)類

Jul 25, 2016 am 08:43 AM

封裝的類:
  1. /*********************************************
  2. 類名: PageSupport
  3. 功能:分頁(yè)顯示mysql數(shù)據(jù)庫(kù)中的數(shù)據(jù)
  4. ***********************************************/
  5. class PageSupport{
  6. //屬性
  7. var $sql; //所要顯示數(shù)據(jù)的SQL查詢語(yǔ)句
  8. var $page_size; //每頁(yè)顯示最多行數(shù)
  9. var $start_index; //所要顯示記錄的首行序號(hào)
  10. var $total_records; //記錄總數(shù)
  11. var $current_records; //本頁(yè)讀取的記錄數(shù)
  12. var $result; //讀出的結(jié)果
  13. var $total_pages; //總頁(yè)數(shù)
  14. var $current_page; //當(dāng)前頁(yè)數(shù)
  15. var $display_count = 30; //顯示的前幾頁(yè)和后幾頁(yè)數(shù)
  16. var $arr_page_query; //數(shù)組,包含分頁(yè)顯示需要傳遞的參數(shù)
  17. var $first;
  18. var $prev;
  19. var $next;
  20. var $last;
  21. //方法
  22. /*********************************************
  23. 構(gòu)造函數(shù):__construct()
  24. 輸入?yún)?shù):
  25. $ppage_size:每頁(yè)顯示最多行數(shù)
  26. ***********************************************/
  27. function PageSupport($ppage_size)
  28. {
  29. $this->page_size=$ppage_size;
  30. $this->start_index=0;
  31. }
  32. /*********************************************
  33. 構(gòu)造函數(shù):__destruct()
  34. 輸入?yún)?shù):
  35. ***********************************************/
  36. function __destruct()
  37. {
  38. }
  39. /*********************************************
  40. get函數(shù):__get()
  41. ***********************************************/
  42. function __get($property_name)
  43. {
  44. if(isset($this->$property_name))
  45. {
  46. return($this->$property_name);
  47. }
  48. else
  49. {
  50. return(NULL);
  51. }
  52. }
  53. /*********************************************
  54. set函數(shù):__set()
  55. ***********************************************/
  56. function __set($property_name, $value)
  57. {
  58. $this->$property_name = $value;
  59. }
  60. /*********************************************
  61. 函數(shù)名:read_data
  62. 功能: 根據(jù)SQL查詢語(yǔ)句從表中讀取相應(yīng)的記錄
  63. 返回值:屬性二維數(shù)組result[記錄號(hào)][字段名]
  64. ***********************************************/
  65. function read_data()
  66. {
  67. $psql=$this->sql;
  68. //查詢數(shù)據(jù),數(shù)據(jù)庫(kù)鏈接等信息應(yīng)在類調(diào)用的外部實(shí)現(xiàn)
  69. $result=mysql_query($psql) or die(mysql_error());
  70. $this->total_records=mysql_num_rows($result);
  71. //利用LIMIT關(guān)鍵字獲取本頁(yè)所要顯示的記錄
  72. if($this->total_records>0)
  73. {
  74. $this->start_index = ($this->current_page-1)*$this->page_size;
  75. $psql=$psql. " LIMIT ".$this->start_index." , ".$this->page_size;
  76. $result=mysql_query($psql) or die(mysql_error());
  77. $this->current_records=mysql_num_rows($result);
  78. //將查詢結(jié)果放在result數(shù)組中
  79. $i=0;
  80. while($row=mysql_fetch_Array($result))
  81. {
  82. $this->result[$i]=$row;
  83. $i++;
  84. }
  85. }
  86. //獲取總頁(yè)數(shù)、當(dāng)前頁(yè)信息
  87. $this->total_pages=ceil($this->total_records/$this->page_size);
  88. $this->first=1;
  89. $this->prev=$this->current_page-1;
  90. $this->next=$this->current_page+1;
  91. $this->last=$this->total_pages;
  92. }
  93. /*********************************************
  94. 函數(shù)名:standard_navigate()
  95. 功能: 顯示首頁(yè)、下頁(yè)、上頁(yè)、未頁(yè)
  96. ***********************************************/
  97. function standard_navigate()
  98. {
  99. echo "
    ";
  100. echo "
    ";
  101. echo "第".$this->current_page."頁(yè)/共".$this->total_pages."頁(yè)";
  102. echo " ";
  103. echo "跳到頁(yè)";
  104. echo "";
  105. //生成導(dǎo)航鏈接
  106. if ($this->current_page > 1) {
  107. echo "first.">首頁(yè)|";
  108. echo "prev.">上一頁(yè)|";
  109. }
  110. if( $this->current_page total_pages) {
  111. echo "next.">下一頁(yè)|";
  112. echo "last.">末頁(yè)";
  113. }
  114. echo "
  115. ";
  116. echo "
";
  • }
  • /*********************************************
  • 函數(shù)名:full_navigate()
  • 功能: 顯示首頁(yè)、下頁(yè)、上頁(yè)、未頁(yè)
  • 生成導(dǎo)航鏈接 如1 2 3 ... 10 11
  • ***********************************************/
  • function full_navigate()
  • {
  • echo "
    ";
  • echo "
    ";
  • echo "第".$this->current_page."頁(yè)/共".$this->total_pages."頁(yè)";
  • echo " ";
  • echo "跳到頁(yè)";
  • echo "";
  • //生成導(dǎo)航鏈接 如1 2 3 ... 10 11
  • $front_start = 1;
  • if($this->current_page > $this->display_count){
  • $front_start = $this->current_page - $this->display_count;
  • }
  • for($i=$front_start;$icurrent_page;$i++){
  • echo "[".$i ."] ";
  • }
  • echo "[".$this->current_page."]";
  • $displayCount = $this->display_count;
  • if($this->total_pages > $displayCount&&($this->current_page+$displayCount)total_pages){
  • $displayCount = $this->current_page+$displayCount;
  • }else{
  • $displayCount = $this->total_pages;
  • }
  • for($i=$this->current_page+1;$i echo "[".$i ."] ";
  • }
  • //生成導(dǎo)航鏈接
  • if ($this->current_page > 1) {
  • echo "first.">首頁(yè)|";
  • echo "prev.">上一頁(yè)|";
  • }
  • if( $this->current_page total_pages) {
  • echo "next.">下一頁(yè)|";
  • echo "last.">末頁(yè)";
  • }
  • echo "
  • ";
  • echo "
  • ";
  • }
  • }
  • ?>
  • 復(fù)制代碼
    寫在php頁(yè)面里面的代碼:
    1. include_once("fenye_php.php"); //引入類
    2. ///////////////////////////////////////////////////////////////////////
    3. $con = mysql_connect("localhost","root","");
    4. if (!$con)
    5. {
    6. die('Could not connect: ' . mysql_error());
    7. }
    8. mysql_select_db("myblog", $con); //選取數(shù)據(jù)庫(kù)
    9. $PAGE_SIZE=10; //設(shè)置每頁(yè)顯示的數(shù)目
    10. ///////////////////////////////////////////////////////////////////////
    11. $pageSupport = new PageSupport($PAGE_SIZE); //實(shí)例化PageSupport對(duì)象
    12. $current_page=$_GET["current_page"];//分頁(yè)當(dāng)前頁(yè)數(shù)
    13. if (isset($current_page)) {
    14. $pageSupport->__set("current_page",$current_page);
    15. } else {
    16. $pageSupport->__set("current_page",1);
    17. }
    18. $pageSupport->__set("sql","select * from article ");
    19. $pageSupport->read_data();//讀數(shù)據(jù)
    20. if ($pageSupport->current_records > 0) //如果數(shù)據(jù)不為空,則組裝數(shù)據(jù)
    21. {
    22. for ($i=0; $icurrent_records; $i++)
    23. {
    24. $title = $pageSupport->result[$i]["title"];
    25. $content = $pageSupport->result[$i]["content"];
    26. $part=substr($content,0,400);
    27. //循環(huán)輸出每條數(shù)據(jù)
    28. echo '
    29. '.$title.'
    30. '.$part.'
    31. update delet
  • ';
  • }
  • }
  • $pageSupport->standard_navigate(); //調(diào)用類里面的這個(gè)函數(shù),顯示出分頁(yè)HTML
  • //關(guān)閉數(shù)據(jù)庫(kù)
  • mysql_close($con);
  • ?>
  • 復(fù)制代碼
    來(lái)自:http://blog.csdn.net/phpfenghuo/article/details/23207099
    分頁(yè), php, mysql


    ? ????? ??
    ? ?? ??? ????? ???? ??? ??????, ???? ?????? ????. ? ???? ?? ???? ?? ??? ?? ????. ???? ??? ???? ???? ??? ?? admin@php.cn?? ?????.

    ? AI ??

    Undresser.AI Undress

    Undresser.AI Undress

    ???? ?? ??? ??? ?? AI ?? ?

    AI Clothes Remover

    AI Clothes Remover

    ???? ?? ???? ??? AI ?????.

    Video Face Swap

    Video Face Swap

    ??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

    ???

    ??? ??

    ???++7.3.1

    ???++7.3.1

    ???? ?? ?? ?? ???

    SublimeText3 ??? ??

    SublimeText3 ??? ??

    ??? ??, ???? ?? ????.

    ???? 13.0.1 ???

    ???? 13.0.1 ???

    ??? PHP ?? ?? ??

    ???? CS6

    ???? CS6

    ??? ? ?? ??

    SublimeText3 Mac ??

    SublimeText3 Mac ??

    ? ??? ?? ?? ?????(SublimeText3)

    ???

    ??? ??

    ??? ????
    1601
    29
    PHP ????
    1502
    276
    ???
    PHP ?? ??? ??????? PHP ?? ??? ??????? Jul 17, 2025 am 04:16 AM

    PHP ?? ??? ?? ???? ?? ? ????? ??? ?????. 1. ?? ??? ??? ??? ??? ? ? ??? ??? ??? ?? ?? ??? ???? ???????. 2. ?? ??? ???? ???? ? ?? ????? ?? ?? ?? ??? ?????. 3. $ _get ? $ _post? ?? Hyperglobal ??? ?? ???? ?? ??? ? ??? ??? ??????? ???????. 4. ?? ?? ?? ???? ?? ?? ?? ??? ?????? ?? ??? ??? ?? ??? ???????. ??? ??? ????? ??? ??? ?? ???? ????? ? ??? ? ? ????.

    PHP?? ?? ???? ???? ???? ??? ?????? PHP?? ?? ???? ???? ???? ??? ?????? Jul 08, 2025 am 02:37 AM

    PHP ?? ???? ???? ????? ?? ? ??? ???? ?? ?? ? ??? ???? ?? ??? ?????? ??? ??? ? ? ???????. 1. ??? ?? CSRF? ???? ?? ??? ??? ???? ?????? ??? ???? FINFO_FILE? ?? ?? MIME ??? ?????. 2. ??? ??? ??? ???? ??? ?? ??? ?? ? WEB ????? ??? ???? ??????. 3. PHP ?? ??? ?? ? ?? ???? NGINX/APACHE? ??? ????? ?? ???? ?????. 4. GD ?????? ??? ? ?? ???? ??? ?? ??? ?? ????.

    PHP?? ?? ?? PHP?? ?? ?? Jul 18, 2025 am 04:57 AM

    PHP ?? ???? ? ?? ???? ??? ????. 1. // ?? #? ???? ? ?? ??? ???? // ???? ?? ????. 2. ?? /.../ ?? ?? ?? ??? ????? ?? ? ?? ??? ?? ? ? ????. 3. ?? ?? ?? / if () {} /? ?? ?? ??? ????? ??? ?? ?? ?? ??? ???? ????? ???? ??? ?? ???? ???? ??? ? ??? ??????.

    PHP?? ???? ??? ?????? PHP?? ???? ??? ?????? Jul 11, 2025 am 03:12 AM

    Ageneratorinphpisamemory- ???? Way-Erate-Overgedatasetsetsbaluesoneatimeatimeatimeatimallatonce.1.generatorsuseTheyieldKeywordTocroadtOpvaluesondemand, RetingMemoryUsage.2

    PHP ?? ?? ? PHP ?? ?? ? Jul 18, 2025 am 04:51 AM

    PHP ??? ???? ??? ??? ??? ????? ????. ??? ????? ?? ???? ??? "?? ? ?"??? "?"? ???????. 1. ??? ? ??? ??? DocBlock (/*/)? ?? ?? ??? ???? ??? ? ?? ???? ??????. 2. JS ??? ???? ?? ???? ??? ?? ??? ??? ?????. 3. ??? ?? ?? ?? ??? ???? ????? ????? ???? ?? ????? ???? ? ??????. 4. Todo ? Fixme? ????? ???? ? ? ??? ??? ???? ?? ?? ? ??? ???????. ??? ???? ?? ??? ??? ?? ?? ?? ???? ???? ? ????.

    ?? PHP : ??? ??? ?? PHP : ??? ??? Jul 18, 2025 am 04:54 AM

    tolearnpheffectical, startBysetTupaloCalserErverEnmentUsingToolslikexamppandacodeeditor -likevscode.1) installxamppforapache, mysql, andphp.2) useacodeeditorforsyntaxsupport.3)) 3) testimplephpfile.next, withpluclucincludechlucincluclucludechluclucled

    PHP?? ??? ? ???? ??? ????? ?? PHP?? ??? ? ???? ??? ????? ?? Jul 12, 2025 am 03:15 AM

    PHP??? ???? ??? ?? ?? ????? ???? ??? ?? ??? ??? ?? ? ??? ??? ???? ?????. ???? 0?? ???? ?? ??? ???? ? ?? ???? ?? ?? ? ? ????. MB_SUBSTR? ?? ??? ??? ???????. ? : $ str = "hello"; echo $ str [0]; ?? H; ??? MB_SUBSTR ($ str, 1,1)? ?? ??? ??? ??? ??????. ?? ???????? ???? ??? ???? ?? ???? ?? ?? ???? ?????? ??? ????? ?? ??? ?? ??? ???? ???? ?? ????.

    ?? PHP ?? ??? ?? PHP ?? ??? Jul 18, 2025 am 04:52 AM

    toinstallphpquickly, usexampponwindowsorhomebrewonmacos.1. ??, downloadandinstallxAmpp, selectComponents, startApache ? placefilesinhtdocs.2

    See all articles