Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [AJAX][PHP] Paginacja ajax + php - problem.
fastlone
post 19.08.2011, 09:51:45
Post #1





Grupa: Zarejestrowani
Postów: 95
Pomógł: 15
Dołączył: 3.06.2010

Ostrzeżenie: (0%)
-----


Cześć.

Znalazłem na internecie plugin do paginacji stron. Od kilku godzin próbuję go wdrożyć w plugin MyBB, lecz bez skutku.
Część kodu pluginu zawierającego tą paginację:
  1. ...
  2.  
  3.  
  4. <?php
  5. function gp_chars_orglist($page)
  6. {
  7. global $db, $mybb, $lang, $page, $templates, $header, $footer, $headerinclude, $menu, $pageTitle, $list, $menu;
  8. if (THIS_SCRIPT == "panel.php" && $mybb->input['action'] == "organisations")
  9. {
  10. add_breadcrumb($lang->gp_organisations, "panel.php?action=organisations");
  11. if ($mybb->settings['gp_chars_orglist'] != 1)
  12. redirect("panel.php", $lang->gp_chars_orglist_off, $lang->gp_title);
  13.  
  14.  
  15. $per_page = 5;
  16. $sql = $db->simple_select("1_organisations", "*", "1=1");
  17. $count = $db->num_rows($sql);
  18. $pages = ceil($count/$per_page);
  19.  
  20.  
  21.  
  22. ?>
  23. <title> <? echo $mybb->settings['bbname']; ?>&nbsp;-&nbsp; <? echo $pageTitle; ?></title>
  24. <? echo $headerinclude; ?>
  25.  
  26. </head><body>
  27. <? echo $header; ?>
  28.  
  29. <style type="text/css">
  30. #containers {
  31. min-height:455px;
  32. padding:12px;
  33. text-align: center;
  34. text-decoration: none;
  35. width: 510px;
  36. overflow:hidden;
  37. margin-top:10px;
  38. }
  39. .shopp
  40. {
  41. border:solid #ccc 1px;
  42. padding:8px;position:relative;
  43. opacity:0;
  44. -webkit-border-radius: 8px;
  45. -moz-border-radius: 8px; font-size:12px;
  46. background:url(remove.png) center right no-repeat 5px;
  47. border-radius: 8px;
  48. font-family:"LubalGraphBdBTBold",Tahoma;
  49. margin-bottom:3px;
  50. text-align:justify;
  51. width:500px;
  52. height:0px;
  53. }
  54.  
  55. #containers .shopp{
  56. color:#000066;
  57. font-family:Arial, Helvetica, sans-serif;
  58. font-size:14px;
  59. padding:5px 5px 12px 5px;
  60. text-align:justify;
  61. margin-bottom:11px;
  62. }
  63.  
  64. .search-background {
  65. display: none;
  66. font-size: 13px;
  67. font-weight: bold;
  68. height:160px;
  69. position: absolute;
  70. padding-top:140px;
  71. text-align: center;
  72. opacity:0.5;filter: alpha(opacity=50) ;
  73. text-decoration: none;
  74. width: 520px;
  75. color:#FFFFFF;
  76. text-shadow: #fff 0px 0px 20px;
  77. }
  78.  
  79. search-background label{
  80.  
  81. border:solid #66FF00 1px;
  82. }
  83.  
  84. #paging_button ul{ width: 510px; padding:0px; margin:8px; }
  85.  
  86. #paging_button ul li {
  87.  
  88. -moz-border-radius: 3px 3px 3px 3px;
  89. background: none repeat scroll 0 0 #000000;
  90. color: #FFFFFF;
  91. float: left;
  92. font-family: helvetica,arial,sans-serif;
  93. font-size: 13px;
  94. font-weight: 700;
  95. margin: 0 2px 0px;
  96. padding: 10px 10px;
  97. text-align: center;
  98. text-decoration: none;
  99. text-shadow: none;
  100. list-style-type:none;
  101. width: 20px;cursor:pointer;
  102. }
  103.  
  104. #paging_button ul li:hover{background:#006699;}
  105. li:hover{ color: #CC0000; cursor: pointer; }
  106. </style>
  107. <script type="text/javascript">
  108. $(document).ready(function(){
  109.  
  110. function showLoader(){
  111.  
  112. $('.search-background').fadeIn(200);
  113. }
  114.  
  115. function hideLoader(){
  116.  
  117. $('.search-background').fadeOut(200);
  118. };
  119.  
  120. $("#paging_button li").click(function(){
  121.  
  122. showLoader();
  123.  
  124. $("#paging_button li").css({'background-color' : ''});
  125. $(this).css({'background-color' : '#006699'});
  126.  
  127. $("#ajaxlist").load("ajaxlist.php?page=" + this.id, hideLoader);
  128.  
  129. return false;
  130. });
  131.  
  132. $("#1").css({'background-color' : '#006699'});
  133. showLoader();
  134. $("#ajaxlist").load("ajaxlist.php?page=1", hideLoader);
  135.  
  136. });
  137.  
  138. </script>
  139.  
  140. <table width='100%'><tr>
  141. <? echo $menu; ?>
  142. <td valign='top'>
  143. <div align="center">
  144.  
  145. <div id="containers">
  146.  
  147. <div class="search-background">
  148. <label><img src="loader.gif" alt="" /></label>
  149. </div>
  150.  
  151. <div id="ajaxlist">
  152. &nbsp;
  153. </div>
  154.  
  155. </div>
  156.  
  157. <div id="paging_button" align="center">
  158. <ul>
  159. <?php
  160. //Show page links
  161. for($i=1; $i<=$pages; $i++)
  162. {
  163. echo '<li id="'.$i.'">'.$i.'</li>';
  164. }?>
  165. </ul>
  166. </div>
  167. </div>
  168.  
  169. </td></tr></table>
  170. <?php
  171.  
  172. echo $footer;
  173.  
  174.  
  175.  
  176.  
  177. }
  178.  
  179.  
  180. }
  181. ?>

Plik ajaxlist.php
  1. <?php
  2. require_once "./global.php";
  3.  
  4. $per_page = 5;
  5. $sqlc = "show columns from mybb_1_organisations";
  6. $rsdc = $db->query($sqlc);
  7. $cols = $db->num_rows($rsdc);
  8. $page = $_REQUEST['page'];
  9. if (empty($page))
  10. $page = 1;
  11.  
  12. $start = ($page-1)*$per_page;
  13. $rsd = $db->simple_select("1_organisations", "*", "1=1", array("order_by" => "www_order", "order_dir" => "ASC", "limit_start" => $start, "limit" => $per_page));
  14.  
  15.  
  16. while ($rows = mysql_fetch_assoc($rsd))
  17. {?>
  18. <div class="shopp">
  19.  
  20. <img src="<?php echo $rows['www_image'];?>" width="80" style="float:left" />
  21. <div class="label"><?php echo substr($rows['Name'],0,150);?></div>
  22.  
  23. </div>
  24. <?php
  25. }
  26. ?>
  27. <script type="text/javascript">
  28. $(document).ready(function(){
  29.  
  30. var Timer = '';
  31. var selecter = 0;
  32. var Main =0;
  33.  
  34. bring(selecter);
  35.  
  36. });
  37.  
  38. function bring ( selecter )
  39. {
  40. $('div.shopp:eq(' + selecter + ')').stop().animate({
  41. opacity : '1.0',
  42. height: '60px'
  43.  
  44. },300,function(){
  45.  
  46. if(selecter < 6)
  47. {
  48. clearTimeout(Timer);
  49. }
  50. });
  51.  
  52. selecter++;
  53. var Func = function(){ bring(selecter); };
  54. Timer = setTimeout(Func, 20);
  55. }
  56.  
  57. </script>


Nie bijcie za mieszanie kodu php i html w jednym pliku, tak samo było zrobione w podstawowej wersji (demo) i działało.
Co jest nie tak w tym kodzie? Proszę o Waszą pomoc.

Pozdrawiam
fastlone

Ten post edytował fastlone 19.08.2011, 09:52:57


--------------------
Nie bój się kliknąć
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 19.07.2025 - 10:09