...

View Full Version : Trying to do pagination with certain format



mfoland
12-03-2010, 05:22 AM
Hello, I am making a playlist for an online radio. The playlist works with Sam Broadcaster. Here is a portion of the script that does some pagination with ABC formatting:


Def($start,0);
Def($limit,20);
Def($search,"");

//########## BUILD SEARCH STRING ################

if(!empty($search))
{
$words = Array();
$temp = explode(' ',$search);
reset($temp);
while(list($key,$val) = each($temp))
{
$val = trim($val);
if(!empty($val))
$words[] = $val;
}


$where2 = "";
reset($words);
while(list($key,$val) = each($words))
{
if(!empty($where2)) $where2 .= " OR ";
$where2 .= " (title like '%$val%') OR (artist like '%$val%') OR (album like '%$val%') ";
}
$where .= "AND ($where2) ";
}

if((isset($letter)) && (!$letter==""))
{
$nextletter = chr(ord($letter)+1);
if($letter=='0')
$where .= " AND NOT((artist>='A') AND (artist<'ZZZZZZZZZZZ')) ";
else
$where .= " AND ((artist>='$letter') AND (artist<'$nextletter')) ";
}
else
{
$letter="";
}

//########## =================== ################

//Calculate total
$db->open("SELECT count(*) as cnt FROM songlist $where ");
$row = $db->row();
$cnt = $row["cnt"];

//Now grab a section of that
$db->open("SELECT * FROM songlist $where ORDER BY artist ASC, title ASC", $limit, $start);

$first = $start+1;
$last = min($cnt,$start+$limit);
$rc = $start;

//$prevlnk = "";
//$nextlnk = "";
//if($cnt>0)
//{
// if(!isset($search))
// { $search=""; }
//$searchstr = urlencode($search);
//$prev = max(0,$start-$limit);
//if($start>0)
//$prevlnk = "<a href='?start=$prev&limit=$limit&letter=$letter&search=$searchstr'>&lt;&lt; Previous</a>";
// $tmp = ($start+$limit);
//if($tmp<$cnt)
//$nextlnk = "<a href='?start=$tmp&limit=$limit&letter=$letter&search=$searchstr'>Next &gt;&gt;</a>";
//}



Obviously the // is stuff commented out because I do not like how that pagination is. the 0 is start for starting at song 1. Limit, obviously 20 per page.. Here is the way I am wanting to format it: http://www.999litefm.com/iplaylist/playlist.html click on the numbers at the bottom and see how it bolds, etc.

Let me explain what some of the info above is in Sam Broadcasters SAMPHP script.

the cnt is the songs total from the database. on the link it goes up to the last song as well. I do not know how to make a pagination like that, or pagination in general. I'm willing to learn. Can someone please build a script to do that, bold and so forth, page: playlist.php?start= first number on list... example: 1-20 it would show start=0..

Thank you so much!

mfoland
12-06-2010, 09:59 PM
Anyone have an idea???? I'm stuck



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum