Jump to content

everything echos on first page


contra10

Recommended Posts

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.