Topic: Display results in a 4x2 display (4 columns, 2 rows) WITH pagination (Read 3356 times)
Just another rainy day
Posts: 1
10 credits Members referred : 0
« on: Feb 10, 2008, 01:06:40 am »
Ok, this one is tricky (for me anyways, one of you guys probably knows this and can do it in your sleep) What I am trying to do is display the results of a mysql query with 8 items on a page and in the following format:
------------------------------------------------------------ | first data | second data | third data | fourth data | ------------------------------------------------------------- | fifth data | sixth data | seventh data | eigth data | ------------------------------------------------------------- <- previous page | next page ->
Now I know how to put query data into columns, and I know how to paginate query data, but they seem to conflict combining them, since they both effect the query itself, sort of driving the query.
I am a metal monkey!
Administrator Community Supporter?
Jedai Sword Master
Gender:
Posts: 5799
46391 credits Members referred : 3
but next you shpuld show us you page we don't provide the solution because you're just asking
Just another rainy day
Posts: 1
6 credits Members referred : 0
« Reply #3 on: Dec 03, 2008, 02:53:17 am »
I actually do have a snippet of code you guys can help me please.
I have created the pagination that I want but now I want to display the results on the page into 4 rows and 5 columns per page. I have got the code to display the 5 rows, but now I can not seem to display the 4 columns accress. How can I do that with the following code? Please help!:
// how many rows we have in database $result = mysql_query($query) or die('Error, query failed'); $numrows = mysql_num_rows($result);
// how many pages we have when using paging? $maxPage = ceil($numrows/$rowsPerPage);
$self = $_SERVER['PHP_SELF'];
// creating 'previous' and 'next' link // plus 'first page' and 'last page' link
// print 'previous' link only if we're not // on page one if ($pageNum > 1) { $page = $pageNum - 1; $prev = " <a href=\"$self?page=$page\">[Prev]</a> ";
$first = " <a href=\"$self?page=1\">[First Page]</a> "; } else { $prev = ' [Prev] ';// we're on page one, don't enable 'previous' link $first = ' [First Page] '; // nor 'first page' link }
// print 'next' link only if we're not // on the last page if ($pageNum < $maxPage) { $page = $pageNum + 1; $next = " <a href=\"$self?page=$page\">[Next]</a> ";
$last = " <a href=\"$self?page=$maxPage\">[Last Page]</a> "; } else { $next = ' [Next] ';// we're on the last page, don't enable 'next' link $last = ' [Last Page] '; // nor 'last page' link }
// print the page navigation link echo $first . $prev . " Showing page <strong>$pageNum</strong> of <strong>$maxPage</strong> pages " . $next . $last;
include 'library/closedb.php'; ?> </body> </html>
Any assistance would be greatly appreciated.
Thanks,
Antonio
Global Moderator Community Supporter?
Jedai Sword Master
Gender:
Posts: 6691
34714 credits Members referred : 374
It's time to use PHP5!
« Reply #4 on: Dec 03, 2008, 06:24:26 am »
do you checked the links I posted before?
My name is Bong, James Bong
Posts: 11
70 credits Members referred : 0