Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Dec 2010
    Posts
    28
    Thanks
    4
    Thanked 0 Times in 0 Posts

    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!

  • #2
    New Coder
    Join Date
    Dec 2010
    Posts
    28
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Anyone have an idea???? I'm stuck


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •