Friday, 9 August 2013

PHP Dynamic Table With Pagination

PHP Dynamic Table With Pagination

I have a list of youtube videos in a flat file database. I would like to
print a thumbnail of these videos out to the end user in a table.
The results need to have pagination as well as a dynamic table so i can
display say 3 rows and 2 columns per page.
The column amount will also need to be adjustable in case i wish to change
the columns from 3 to 4 for example:
$video_file_data[]; //This is the array in which all video
info will be stored
$start = $_REQUEST['start']; //pagination setting
$videos_per_page = 9; //Show 9 Vids per page
$table_colums = 3; //Amount of columns needed to display
results per page
$num = count ($video_file_data); //Number of lines in data array
$max_pages = @ceil($num / $videos_per_page); //Maximum number of Pages
$cur = @ceil($start / $videos_per_page)+1;
for($i=$start;$i<min($num,($start+$videos_per_page)+0);$i++) {
list($date_added, $video_title, $youtube_url) = explode('|',
trim($video_file_data[$i]));
// <--- Table needs to go
}
The info stored in $video_file_data[] would be something like this:
date 1."|".title 1."|".youtube url 1
date 2."|".title 2."|".youtube url 2
date 3."|".title 3."|".youtube url 3
date 4."|".title 4."|".youtube url 4

No comments:

Post a Comment