Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-03-2010, 04:22 AM   PM User | #1
mfoland
New Coder

 
Join Date: Dec 2010
Posts: 28
Thanks: 4
Thanked 0 Times in 0 Posts
mfoland is an unknown quantity at this point
Exclamation Trying to do pagination with certain format

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:

PHP Code:
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 is offline   Reply With Quote
Old 12-06-2010, 08:59 PM   PM User | #2
mfoland
New Coder

 
Join Date: Dec 2010
Posts: 28
Thanks: 4
Thanked 0 Times in 0 Posts
mfoland is an unknown quantity at this point
Anyone have an idea???? I'm stuck
mfoland is offline   Reply With Quote
Reply

Bookmarks

Tags
coding, music, php, playlist

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:01 PM.


Advertisement
Log in to turn off these ads.