contra10 Posted October 31, 2009 Share Posted October 31, 2009 ok I'm using my pagination script and everything seems to be echoing on the first page and every other page <?php //This checks to see if there is a page number. If not, it will set it to page 1 $pagenum = $_GET['pagenum']; $linkgenre = $_GET['l']; if ($pagenum) { } else{ $pagenum = 1; } //Here we count the number of results $querye = "SELECT DISTINCT * FROM `musiclinks` WHERE `genre` ='$linkgenre' AND `embed` = 'True'"; $result = mysql_query($querye); $rows= mysql_num_rows($result); //This is the number of results displayed per page $page_rows = 5; $es = ($rows/$page_rows); //This tells us the page number of our last page $last = ceil($es); //this makes sure the page number isn't below one, or more than our maximum pages if ($pagenum < 1) { $pagenum = 1; } elseif ($pagenum > $last) { $pagenum = $last; } //This sets the range to display in our query $max = 'LIMIT ' .($pagenum - 1) * $page_rows .',' .$page_rows; //This is your query again, the same one... the only difference is we add $max into it $data_p = mysql_query("SELECT * FROM `musiclinks` WHERE `genre` = '$linkgenre' AND `embed` = 'True' $max"); if ($data_p){ //This is where you display your query results while ($postede = mysql_fetch_assoc($result)) { $name = "{$postede['title']}"; $genre = "{$postede['genre']}"; $filename = "{$postede['filename']}"; echo "<tr><td width='%50'><a href='http://www.site.com/music/plisten.php?f=$filename'>$name</a></td><td width='%50'>$genre</td>"; $queryear = "SELECT * FROM `ratings` WHERE `songtitle` = '$name'"; $resultear = mysql_query($queryear) or die(mysql_error()); while ($postedear = mysql_fetch_assoc($resultear)) { $avsong = "{$postedear['songtitle']}"; $linksong = "{$postedear['song']}"; $ratedavg = "{$postedear['average']}"; if ($ratedavg > 1){ echo"<td>$ratedavg / 10</td></tr>"; }else{ echo "<td>No Rating</td></tr>"; } } } // This shows the user what page they are on, and the total number of pages echo " Page $pagenum of $last ($rows Results)<p>";?> I don't understand why its not working and the max variable changes when i click on a different page Link to comment https://forums.phpfreaks.com/topic/179707-everything-echos-on-first-page/ Share on other sites More sharing options...
contra10 Posted October 31, 2009 Author Share Posted October 31, 2009 is there something wron with the max variable Link to comment https://forums.phpfreaks.com/topic/179707-everything-echos-on-first-page/#findComment-948187 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.