Xtremer360 Posted November 22, 2010 Share Posted November 22, 2010 This pagination code came straight from a book and I went back over it so it must be the book that is wrong or something because I'm getting a Parse error: parse error in C:\wamp\www\KOW Manager\mods\templates.php on line 114 and line 114 is if ($current_page ! = 1) { if ($pages > 1) { // Determine what page the script is on: $current_page = ($start/$display) + 1; // If its not the first page, make a Previous button if ($current_page ! = 1) { echo '<span class="prev disabled"><a href="templates.php?s=' . ($start - $display) . '$p=' . $pages . '"><<</a></span>'; } // Make all the numbered pages: for ($i = 1; $i <= $pages, $i++) { if ($i ! = $current_page) { echo '<span class="current roundedBordersLite"><a href="templates.php?s=' . (($display * ($i - 1))). '$p=' . $pages . '">' . $i . '</a></span>'; } else { echo $i . ' '; } } // End of FOR Loop. // If its not the last page, make a Next button: if ($current_page ! = $pages) { echo '<span class="next"><a href="#">>></a></span>'; } } // End of links pages. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted November 22, 2010 Share Posted November 22, 2010 It should be: != Quote Link to comment Share on other sites More sharing options...
Xtremer360 Posted November 22, 2010 Author Share Posted November 22, 2010 Wow okay that was somethign I should have seen. What about Parse error: parse error, expecting `';'' on line 119 Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted November 22, 2010 Share Posted November 22, 2010 Your for() statement has a comma instead of a semi-colon in it. Quote Link to comment Share on other sites More sharing options...
Xtremer360 Posted November 22, 2010 Author Share Posted November 22, 2010 Great now after I fix this LAST LAST issue I can apply all of this stuff to my other files so they will all be correct. I don't understand why I'm getting this message now: Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given on line 15 <?php // Include the database page include ('../inc/dbconfig.php'); // Number of records to show per page $display = 10; if (isset($_GET['p']) && is_numeric($_GET['p'])) { $pages = $_GET['p']; } else { // Need to determine // Count the number of records $q = "SELECT COUNT (id) FROM templates"; $r = mysqli_query ($dbc, $q); $row = mysqli_fetch_array($r, MYSQLI_NUM); $records = $row[0]; // Calculate the number of pages... if ($records > $display) { // More than 1 page. $pages = ceil($records/$display); } else { $pages = 1; } } // End of p IF. // Determine where in the database to start returning results... if (isset($_GET['s']) && is_numeric($_GET['s'])) { $start = $_GET['s']; } else { $start = 0; } // End of s IF. $query = "SELECT CONCAT_WS(' ', firstname, lastname) AS name, DATE_FORMAT(datecreated, '%M %d, %Y') AS datecreated, templatename FROM templates, users WHERE users.id = templates.creator_id LIMIT $start, $display"; $result = mysqli_query ( $dbc, $query ); // Run The Query $rows = mysqli_num_rows($result); ?> <!-- Title --> <div id="title" class="b2"> <h2>Templates</h2> <!-- TitleActions --> <div id="titleActions"> <!-- ListSearch --> <div class="listSearch actionBlock"> <div class="search"> <label for="search">Recherche</label> <input type="text" name="search" id="search" class="text" /> </div> <div class="submit"> <button type="submit" id="search-button" class="button"><strong><img src="img/icons/search_48.png" alt="comments" class="icon "/></strong></button> </div> </div> <!-- /ListSearch --> <!-- newPost --> <div class="newPost actionBlock"> <a href="#" class="button"><strong>New post<img src="img/icons/add_48.png" alt="new post" class="icon "/></strong></a> </div> <!-- /newPost --> </div> <!-- /TitleActions --> </div> <!-- Title --> <!-- Inner Content --> <div id="innerContent"> <!-- ListHeader --> <div id="listHeader"> <p class="listInfos"> You have <?php if($rows == 0){echo '0';}else{echo $rows;} ?> templates. </p> <div class="listActions"> <form action="" method="post"> <label for="actionSelect">With selected items: </label> <select class="select" name="actionSelect" id="actionSelect"> <option>Edit</option> <option>Delete</option> </select> <button class="button small-button"><strong>Apply</strong></button> </form> </div> </div> <!-- /ListHeader --> <?php if ($rows > 0) { ?> <!-- ListTable --> <table cellspacing="0" class="listTable" id="postList"> <!-- Thead --> <thead> <tr> <th class="first"><div></div></th> <th><a href="#" title="Template Name">Template Name</a></th> <th><a href="#" title="Author">Creator</a></th> <th class="last"><a href="#" title="Date">Date Created</a></th> </tr> </thead> <!-- /Thead --> <!-- Tfoot --> <tfoot> <tr> <td colspan="5"> <div class="inner"> <div class="paginate"> <?php if ($pages > 1) { // Determine what page the script is on: $current_page = ($start/$display) + 1; // If its not the first page, make a Previous button if ($current_page != 1) { echo '<span class="prev disabled"><a href="templates.php?s=' . ($start - $display) . '$p=' . $pages . '"><<</a></span>'; } // Make all the numbered pages: for ($i = 1; $i <= $pages; $i++) { if ($i != $current_page) { echo '<span class="current roundedBordersLite"><a href="templates.php?s=' . (($display * ($i - 1))). '$p=' . $pages . '">' . $i . '</a></span>'; } else { echo $i . ' '; } } // End of FOR Loop. // If its not the last page, make a Next button: if ($current_page != $pages) { echo '<span class="next"><a href="#">>></a></span>'; } } // End of links pages. ?> </div> </div> </td> </tr> </tfoot> <!-- /Tfoot --> <!-- Tbody --> <tbody> <?php while ( $row = mysqli_fetch_array ( $result, MYSQL_ASSOC ) ) { echo ' <tr> <td><input type=checkbox class=checkbox /></td> <td><a href=# title=' . $row['templatename'] . '>' . $row['templatename'] . '</a></td> <td><a href=# title=' . $row['name'] . '>' . $row['name'] . '</a></td> <td class=last title=' . $row['datecreated'] . '>' . $row['datecreated'] . '</td> </tr>'; } ?> </tbody> <!-- /Tbody --> </table> <?php } ?> <!-- /ListTable --> </div> <!-- /Inner Content --> Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted November 22, 2010 Share Posted November 22, 2010 The query is failing and returning a boolean FALSE to the mysqli_fetch_array() function. $r = mysqli_query($dbc, $q) or die( "<br>Query string: $q<br>Error: " . mysqli_error($dbc) . '<br>'); Quote Link to comment Share on other sites More sharing options...
Xtremer360 Posted November 22, 2010 Author Share Posted November 22, 2010 This is what it says: Query string: SELECT COUNT (id) FROM templates Error: FUNCTION kowmanager.COUNT does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual kowmanager is the name of my database Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted November 22, 2010 Share Posted November 22, 2010 Remove the space between COUNT and ( Quote Link to comment Share on other sites More sharing options...
Xtremer360 Posted November 22, 2010 Author Share Posted November 22, 2010 Thank you fixed that problem. However, lets say I have 4 templates stored in my database. If I assign the display variable any number above the amount of templates in the database it will properly display that correct number where it says "You have <?php if($rows == 0){echo '0';}else{echo $rows;} ?> templates." however with my pagination if say to test it, I put 2 for the display variable, which means it would have 2 pages with 2 templates displayed on each page. The issue is when I do that it then displays how many the "You have how many templates like above it puts the amount of the display variable and not sure why. Quote Link to comment Share on other sites More sharing options...
Xtremer360 Posted November 22, 2010 Author Share Posted November 22, 2010 Anyone new want to take a shot? Quote Link to comment Share on other sites More sharing options...
Xtremer360 Posted November 23, 2010 Author Share Posted November 23, 2010 I tried working on this all day and am dead lost. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted November 23, 2010 Share Posted November 23, 2010 If you find a post is being viewed, but getting no responses, it is a pretty good indicator that no one understands it. Posting an example of your data (or fake data), with the expected output, and the incorrect output, would be worth a 1000 words. Quote Link to comment Share on other sites More sharing options...
Xtremer360 Posted November 23, 2010 Author Share Posted November 23, 2010 If you click on the templates link under the Site Admin on the left and view its contents in the the content div on the right you'll see it says you'll see that it says "You have 4 templates" which is correct in my DB I do have four. I get that by using mysqli_num_rows to have it echo out the number of returned rows from my query. The problem I'm having is that with my pagination code. I have it preset to display 10 records per page, however if I put 2 for my display variables it turns into "You have 2 templates". http://defiantwrestling.net/efedmanager/index2 <?php // Include the database page include ('../inc/dbconfig.php'); // Number of records to show per page $display = 10; if (isset($_GET['p']) && is_numeric($_GET['p'])) { $pages = $_GET['p']; } else { // Need to determine // Count the number of records $q = "SELECT COUNT(id) FROM templates"; $r = mysqli_query($dbc, $q); $row = mysqli_fetch_array($r, MYSQLI_NUM); $records = $row[0]; // Calculate the number of pages... if ($records > $display) { // More than 1 page. $pages = ceil($records/$display); } else { $pages = 1; } } // End of p IF. // Determine where in the database to start returning results... if (isset($_GET['s']) && is_numeric($_GET['s'])) { $start = $_GET['s']; } else { $start = 0; } // End of s IF. $query = "SELECT CONCAT_WS(' ', firstname, lastname) AS name, DATE_FORMAT(templates.datecreated, '%M %d, %Y') AS datecreated, templatename FROM templates, handlers WHERE handlers.id = templates.creator_id LIMIT $start, $display"; $result = mysqli_query ( $dbc, $query ); // Run The Query $rows = mysqli_num_rows($result); ?> <!-- Title --> <div id="title" class="b2"> <h2>Templates</h2> <!-- TitleActions --> <div id="titleActions"> <!-- ListSearch --> <div class="listSearch actionBlock"> <div class="search"> <label for="search">Recherche</label> <input type="text" name="search" id="search" class="text" /> </div> <div class="submit"> <button type="submit" id="search-button" class="button"><strong><img src="img/icons/search_48.png" alt="comments" class="icon "/></strong></button> </div> </div> <!-- /ListSearch --> <!-- newPost --> <div class="newPost actionBlock"> <a href="#" class="button"><strong>Add New Template<img src="img/icons/add_48.png" alt="new post" class="icon "/></strong></a> </div> <!-- /newPost --> </div> <!-- /TitleActions --> </div> <!-- Title --> <!-- Inner Content --> <div id="innerContent"> <!-- ListHeader --> <div id="listHeader"> <p class="listInfos"> You have <?php if($rows == 0){echo '0';}else{echo $rows;} ?> templates. </p> <div class="listActions"> <form action="" method="post"> <label for="actionSelect">With selected items: </label> <select class="select" name="actionSelect" id="actionSelect"> <option>Edit</option> <option>Delete</option> </select> <button class="button small-button"><strong>Apply</strong></button> </form> </div> </div> <!-- /ListHeader --> <?php if ($rows > 0) { ?> <!-- ListTable --> <table cellspacing="0" class="listTable" id="postList"> <!-- Thead --> <thead> <tr> <th class="first"><div></div></th> <th><a href="#" title="Template Name">Template Name</a></th> <th><a href="#" title="Creator">Creator</a></th> <th class="last"><a href="#" title="Date Created">Date Created</a></th> </tr> </thead> <!-- /Thead --> <!-- Tfoot --> <tfoot> <tr> <td colspan="5"> <div class="inner"> <div class="paginate"> <?php if ($pages > 1) { // Determine what page the script is on: $current_page = ($start/$display) + 1; // If its not the first page, make a Previous button if ($current_page != 1) { echo '<span class="prev disabled"><a href="templates.php?s=' . ($start - $display) . '$p=' . $pages . '"><<</a></span>'; } // Make all the numbered pages: for ($i = 1; $i <= $pages; $i++) { if ($i != $current_page) { echo '<span class="current roundedBordersLite"><a href="templates.php?s=' . (($display * ($i - 1))). '$p=' . $pages . '">' . $i . '</a></span>'; } else { echo $i . ' '; } } // End of FOR Loop. // If its not the last page, make a Next button: if ($current_page != $pages) { echo '<span class="next"><a href="#">>></a></span>'; } } // End of links pages. ?> </div> </div> </td> </tr> </tfoot> <!-- /Tfoot --> <!-- Tbody --> <tbody> <?php while ( $row = mysqli_fetch_array ( $result, MYSQL_ASSOC ) ) { echo ' <tr> <td><input type=checkbox class=checkbox /></td> <td>' . $row['templatename'] . '</td> <td>' . $row['name'] . '</td> <td class=last>' . $row['datecreated'] . '</td> </tr>'; } ?> </tbody> <!-- /Tbody --> </table> <?php } ?> <!-- /ListTable --> </div> <!-- /Inner Content --> Quote Link to comment Share on other sites More sharing options...
Xtremer360 Posted November 23, 2010 Author Share Posted November 23, 2010 I was hoping what I last put made more sense. Quote Link to comment 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.