Witam mam pewien problem z kodem pewnego skryptu znalezionego w sieci, mianowicie nie mogę poradzić sobie z implementacją stronicowania, próbowałem już chyba wszelkich kombinacji lecz nie dało to rezultatów sad.gif
Oto kod:
  1. <?php
  2. include_once('inc_dbcon.php');
  3. require_once('admin/config.php');
  4. require_once($languageFile);
  5.  
  6. // Preview descrition length in characters
  7. $previewLength = 240;
  8.  
  9. // check to see if in admin mode and validate key
  10. global $keyOut;
  11. $keyOut = "";
  12. if (isset($_GET["k"]))
  13. if($_GET["k"] == $key){ // Key comes from admin/password.php file
  14. $keyOut = "&k=" . $key;
  15. }
  16.  
  17. global $category;
  18. $category = "%";
  19. if (isset($_GET["category"]))
  20. $category = mysql_real_escape_string($_GET["category"]);
  21.  
  22. $msg = "";
  23. if (isset($_GET["msg"]))
  24. $msg = mysql_real_escape_string($_GET["msg"]);
  25.  
  26. // SEARCH CODE START
  27. $searchQuery = "";
  28. if (isset($_GET["q"]))
  29. $searchQuery = mysql_real_escape_string($_GET["q"]);
  30.  
  31. if ($searchQuery != "")
  32. {
  33. $query_Recordset1 = "SELECT postId,category,title,description,isAvailable,description,price,confirmPassword,
    category,imgURL,imgURLThumb,DATE_FORMAT(timeStamp,'%b %d, %Y %l:%i %p') AS timeStamp1 FROM md_postings WHERE isConfirmed = '1' AND title like '%$searchQuery%' OR description like '%searchQuery%' ORDER BY `timeStamp` DESC"
    ;
  34. } else {
  35. // this following line was pulled from about ten lines below if you are updating an older version
  36. $query_Recordset1 = "SELECT postId,category,title,description,isAvailable,description,price,confirmPassword,
    category,imgURL,imgURLThumb,DATE_FORMAT(timeStamp,'%b %d, %Y %l:%i %p') AS timeStamp1 FROM md_postings WHERE isConfirmed = '1' AND category like '$category' ORDER BY `timeStamp` DESC"
    ;
  37. }
  38. // SEARCH CODE END - see also line 113 below
  39.  
  40. $maxRows_Recordset1 = 100;
  41. $pageNum_Recordset1 = 0;
  42. if (isset($_GET['pageNum_Recordset1'])) {
  43. $pageNum_Recordset1 = mysql_real_escape_string($_GET['pageNum_Recordset1']);
  44. }
  45. $startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;
  46.  
  47. $query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
  48. $Recordset1 = mysql_query($query_limit_Recordset1);
  49. if (!$Recordset1){
  50. print("It appears we have a problem: " . mysql_error());
  51. exit();
  52. }
  53. $row_Recordset1 = mysql_fetch_assoc($Recordset1);
  54. if (isset($_GET['totalRows_Recordset1'])) {
  55. $totalRows_Recordset1 = mysql_real_escape_string($_GET['totalRows_Recordset1']);
  56. } else {
  57. $all_Recordset1 = mysql_query($query_Recordset1);
  58. $totalRows_Recordset1 = mysql_num_rows($all_Recordset1);
  59. }
  60. $totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;
  61. $queryString_Recordset1 = "";
  62. if (!empty($_SERVER['QUERY_STRING'])) {
  63. $params = explode("&", $_SERVER['QUERY_STRING']);
  64. $newParams = array();
  65. foreach ($params as $param) {
  66. if (stristr($param, "pageNum_Recordset1") == false &&
  67. stristr($param, "totalRows_Recordset1") == false) {
  68. array_push($newParams, $param);
  69. }
  70. }
  71. if (count($newParams) != 0) {
  72. $queryString_Recordset1 = "&" . htmlentities(implode("&", $newParams));
  73. }
  74. }
  75. $queryString_Recordset1 = sprintf("&totalRows_Recordset1=%d%s", $totalRows_Recordset1, $queryString_Recordset1);
  76.  
  77. ?>
  78. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  79. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
  80. <head>
  81. <title></title>
  82. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  83. <link href="md_style.css" rel="stylesheet" type="text/css" />
  84. <script language="JavaScript">
  85. function doFilter(dis)
  86. {
  87. window.location.href = "index.php?category=<?php echo $category ?>&type=" + dis.value + "<?php echo $keyOut;?>"
  88. }
  89. </script>
  90. </head>
  91. <body>
  92. <?php include_once("inc_navigation.php") ;?>
  93. <div id="md_container">
  94.  
  95. <?php
  96. if ($msg == "deleted")
  97. print("<br clear='all' />&nbsp;<div class='md_msg' style='margin-top:-10px;'>" . STR_DELETED ."</div>");
  98. ?>
  99. <br clear="all" />
  100. <div id='md_listingBox'>
  101. <?php
  102. if($totalRows_Recordset1 < 1)
  103. {
  104. // SEARCH START new Code - added IF statement to support search
  105. if ($searchQuery != "")
  106. echo "<p><br /><br /><br />" . STR_NORESULTS . "<b>" . $searchQuery ."</b></p>";
  107. else
  108. echo "<p><br /><br /><br />" . STR_NOITEMS . "</p>";
  109. // SEARCH END NEW CODE
  110. } else {
  111.  
  112. do {
  113. $img = "/images/gift_light.gif' title='This is a gift!'";
  114. $type = $row_Recordset1['type'];
  115. $isAvailable = $row_Recordset1['isAvailable'];
  116. $isAvailableClass = ($isAvailable == 0) ? 'md_taken' : '';
  117. $thumbnail = '&nbsp;';
  118. if (strlen($row_Recordset1['imgURLThumb']) > 3){
  119. $thumbnail = "<a href='viewItem.php?id=" . $row_Recordset1['postId'] . "' class='md_recordLink " . $isAvailableClass . "'>";
  120. $thumbnail .= "<img src='" . $row_Recordset1['imgURLThumb'] . "' class='md_thumbnail' border='0'></a>";
  121. }
  122. ?>
  123. <table width="100%" border="0" cellpadding="4" class="md_listingTable">
  124. <tr>
  125. <td width="54" align="center"><?php echo $thumbnail; ?></td>
  126. <td valign="top">
  127. <div class='md_date'><?php echo $row_Recordset1['timeStamp1'];?></div>
  128. <a href="viewItem.php?id=<?php echo $row_Recordset1['postId'] . $keyOut;?>"
  129. class='md_recordLink<?php echo $isAvailableClass; ?>'><?php echo stripslashes($row_Recordset1['title']); ?></a>
  130. — $<?php echo $row_Recordset1['price']; ?> <br />
  131. <?php echo stripslashes(substr($row_Recordset1['description'],0,$previewLength)); ?>...
  132. </td>
  133. </tr>
  134. </table>
  135. <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1));
  136. } // end else clause
  137. ?>
  138.  
  139. </div>
  140. </div>
  141. <?php include_once("inc_footer.php");?>
  142. </body>
  143. </html>
  144. <?php mysql_close($dbConn); ?>

Z góry dziękuję za pomoc