steviez Posted June 17, 2007 Share Posted June 17, 2007 Hi, I have a php page that i want to limit the number of items shown on it, i have used a code to generate a previous and next button but for some reson it wont work. Please could someone look at the code bellow and tell me whats wrong and what i need to do to make it work. Thanks <?php include("members_folder_header.php"); require_once("admin/config.php"); require_once("conn.php"); include "admin/conn.php"; include "admin/functions.php"; $username = $_GET['user']; $maxRows_rsFiles = 3000; $pageNum_rsFiles = 0; if (isset($_GET['pageNum_rsFiles'])) { $pageNum_rsFiles = $_GET['pageNum_rsFiles']; } $startRow_rsFiles = $pageNum_rsFiles * $maxRows_rsFiles; mysql_select_db($database_dcon, $dcon); $query_rsFiles = "SELECT * FROM xl_members_files WHERE public = 'Yes' AND username = '".$username."'"; $query_limit_rsFiles = sprintf("%s LIMIT %d, %d", $query_rsFiles, $startRow_rsFiles, $maxRows_rsFiles); $rsFiles = mysql_query($query_limit_rsFiles, $dcon) or die(mysql_error()); $row_rsFiles = mysql_fetch_assoc($rsFiles); if (isset($_GET['totalRows_rsFiles'])) { $totalRows_rsFiles = $_GET['totalRows_rsFiles']; }else{ $all_rsFiles = mysql_query($query_rsFiles); $totalRows_rsFiles = mysql_num_rows($all_rsFiles); } $totalPages_rsFiles = ceil($totalRows_rsFiles/$maxRows_rsFiles)-1; ?> <div id="user_tabulka"> <br /> <table border="0" cellpadding="0" cellspacing="0" width="98%" align="center"> <tbody> <tr id="tabulka_popisky"> <td width="8%"><li>No</li></td> <td width="28%"><li>File Name </li></td> <td align="left" width="17%"><li>Size</li></td> <td width="16%"><li>Download</li></td> </tr> <?php $cn = $startRow_rsFiles; $row_bg_color = "#f5f5f5"; do { $cn++; if($row_bg_color == "#f5f5f5"){ $row_bg_color = "#ffffff"; }else{ $row_bg_color = "#f5f5f5"; } ?> <tr class="tmavej_radek highlight" style="cursor:pointer;"> <td><?php echo $cn; ?></td> <td><?php echo $row_rsFiles['filename']; ?></td> <td><?php echo number_format($row_rsFiles['filesize']/1048576,2); ?> (MB)</td> <td><a href="<?php echo SITE_URL."/v2/".$row_rsFiles['key']."/".$row_rsFiles['filename'].".html"; ?>" target="_blank">Click here</a></td> </tr> <?php } while ($row_rsFiles = mysql_fetch_assoc($rsFiles)); ?> <tr> <td colspan="6" align="left" class="tmavej_radek highlight"><?php if ($pageNum_rsFiles > 0) { // Show if not first page ?> <a href="<?php printf("%s?pageNum_rsFiles=%d%s", $currentPage, 0, $queryString_rsFiles); ?>" class="prevnext">First</a> <?php } else { echo "First"; } // Show if not first page ?> <?php if ($pageNum_rsFiles > 0) { // Show if not first page ?> <a href="<?php printf("%s?pageNum_rsFiles=%d%s", $currentPage, max(0, $pageNum_rsFiles - 1), $queryString_rsFiles); ?>" class="prevnext">Previous</a> <?php } else { echo "Previous"; } // Show if not first page ?> <?php if ($pageNum_rsFiles < $totalPages_rsFiles) { // Show if not last page ?> <a href="<?php printf("%s?pageNum_rsFiles=%d%s", $currentPage, min($totalPages_rsFiles, $pageNum_rsFiles + 1), $queryString_rsFiles); ?>" class="prevnext">Next</a> <?php } else { echo "Next"; } // Show if not last page ?> <?php if ($pageNum_rsFiles < $totalPages_rsFiles) { // Show if not last page ?> <a href="<?php printf("%s?pageNum_rsFiles=%d%s", $currentPage, $totalPages_rsFiles, $queryString_rsFiles); ?>" class="prevnext">Last</a> <?php } else { echo "Last"; } // Show if not last page ?> </td> </tr> </tbody> </table> </div> <div id="footer"><?php include("footer.php"); ?></div> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/55903-solved-page-help/ Share on other sites More sharing options...
steviez Posted June 17, 2007 Author Share Posted June 17, 2007 can anyone help at all? im desperate for this Quote Link to comment https://forums.phpfreaks.com/topic/55903-solved-page-help/#findComment-276248 Share on other sites More sharing options...
king arthur Posted June 17, 2007 Share Posted June 17, 2007 You shouldn't need to do all that stuff with the different queries to get the rows. Just use $query_rsFiles = "SELECT * FROM xl_members_files WHERE public = 'Yes' AND username = '$username' limit $startRow_rsFiles, $maxRows_rsFiles"; Your main problem however is that I see no loop anywhere that iterates through the rows returned? Quote Link to comment https://forums.phpfreaks.com/topic/55903-solved-page-help/#findComment-276309 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.