Advertisement
Guest User

Untitled

a guest
Feb 29th, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.85 KB | None | 0 0
  1. <html>
  2. <head>
  3. <title>All </title>
  4. </head>
  5. <body>
  6. <?php
  7. $dbhost = "localhost";
  8. $dbusername = "root";
  9. $dbpassword = "";
  10. $dbname = "drill";
  11. $mysqli = new mysqli ($dbhost, $dbusername, $dbpassword, $dbname);
  12.  
  13. $strSQL = "SELECT * FROM data ";
  14. $objQuery = mysqli_query($mysqli,$strSQL);
  15.  
  16. $Num_Rows = mysqli_num_rows($objQuery);
  17.  
  18. $Per_Page = 2; // Per Page
  19.  
  20. $Page = $_GET["Page"];
  21. if(!$_GET["Page"])
  22. {
  23. $Page=1;
  24. }
  25.  
  26. $Prev_Page = $Page-1;
  27. $Next_Page = $Page+1;
  28.  
  29. $Page_Start = (($Per_Page*$Page)-$Per_Page);
  30. if($Num_Rows<=$Per_Page)
  31. {
  32. $Num_Pages =1;
  33. }
  34. else if(($Num_Rows % $Per_Page)==0)
  35. {
  36. $Num_Pages =($Num_Rows/$Per_Page) ;
  37. }
  38. else
  39. {
  40. $Num_Pages =($Num_Rows/$Per_Page)+1;
  41. $Num_Pages = (int)$Num_Pages;
  42. }
  43.  
  44.  
  45. $strSQL .=" order by no ASC LIMIT $Page_Start , $Per_Page";// no is autoincrement
  46.  
  47. $objQuery = mysqli_query($mysqli,$strSQL);
  48. ?>
  49. <table width="600" border="1">
  50. <tr>
  51. <th width="91"> <div align="center">no</div></th>
  52. <th width="98"> <div align="center">campaign </div></th>
  53. <th width="198"> <div align="center">url</div></th>
  54.  
  55. </tr>
  56. <?php
  57. while($objResult = mysqli_fetch_array($objQuery,MYSQLI_ASSOC))
  58. {
  59. ?>
  60. <tr>
  61. <td><div align="center"><?php echo $objResult["no"];?></div></td>
  62. <td><div align="center"><?php echo $objResult["camp"];?></div></td>
  63. <td><div align="center"><?php echo $objResult["url"];?></div></td>
  64.  
  65. </tr>
  66. <?php
  67. }
  68. ?>
  69. </table>
  70.  
  71. <br>
  72. Total <?php echo $Num_Rows;?> Record : <?php echo $Num_Pages;?> Page :
  73. <?php
  74. if($Prev_Page)
  75. {
  76. echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page'><< Back</a> ";
  77. }
  78.  
  79. for($i=1; $i<=$Num_Pages; $i++){
  80. if($i != $Page)
  81. {
  82. echo "[ <a href='$_SERVER[SCRIPT_NAME]?Page=$i'>$i</a> ]";
  83. }
  84. else
  85. {
  86. echo "<b> $i </b>";
  87. }
  88. }
  89. if($Page!=$Num_Pages)
  90. {
  91. echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page'>Next>></a> ";
  92. }
  93. mysqli_close($mysqli);
  94. ?>
  95. </body>
  96. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement