Code: Select all
http://yourdomain.com/dl.php?alpha=a&artist=somthng
Code: Select all
function track($alpha,$cats)
{
if($_GET['page']) // Is page defined?
{
$page = $_GET['page']; // Set to the page defined
}else{
$page = 1; // Set to default page 1
}
$max = 10; // Set maximum to 10
$cur = (($page * $max) - $max ); // Work out what results to show
$getdata = mysql_query("SELECT * FROM `cr-mp3` WHERE alpha='".$alpha."' ORDER BY `id` DESC LIMIT $cur, $max") or die(mysql_error()); // select the results
$getdata2 = mysql_query("SELECT * FROM `cr-mp3` WHERE alpha='".$alpha."' ORDER BY `id` DESC LIMIT $cur, $max") or die(mysql_error()); // select the results2
$data = mysql_fetch_array($getdata); // get the data
$counttotal = mysql_query("SELECT * FROM `cr-mp3` WHERE alpha='".$alpha."' ") or die(mysql_error()); // select all records
$counttotal = mysql_num_rows($counttotal); // count records
$total_pages = ceil($counttotal / $max); // dive the total, by the maximum results to show
$pgy = $_GET['page'];
if($pgy > 1)
{
$nxt_tag = "«";
}
else
{
$nxt_tag = "»";
}
while($sql3 = mysql_fetch_array($getdata2)) {
$link = $sql3[0];
$name = $sql3[2];
$artist = $sql3[1];
echo "» ";
echo "<a href=\"../get.php?step=1&id=$link\">";
echo "$artist - $name";
echo "</a><br />\n";
}
for($i = 1; $i <= $total_pages; $i++) // for each page number
{
if($page == $i) // if this page were about to echo = the current page
{
echo' '.$nxt_tag.' <b>' . $i .'</b> '; // echo the page number bold
}
else {
echo ' '.$nxt_tag.' <a href="?page=' . $i . '&alpha=' .$alpha. '">' . $i . '</a> '; // echo a link to the page
}
}
if($page > 1){ // is the page number more than 1?
$prev = ($page - 1); // if so, do the following. take 1 away from the current page number
echo '<br /><a href="?page=' . $prev . '&alpha=' .$alpha. '">« Previous</a>'; // echo a previous page link
}
if($page < $total_pages){ // is there a next page?
$next = ($page + 1); // if so, add 1 to the current
echo '<br/><a href="?page=' . $next . '&alpha=' .$alpha. '">Next »</a>'; // echo the next page link
}
}