29, May 2012

Display results in a 4x2 display (4 columns, 2 rows) WITH pagination - webmaster forum

 
Webdigity webmaster forums
[ Home | Help | Search | Forum's Shop | Archive | Login | Register | Webmaster Directory ]
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: Display results in a 4x2 display (4 columns, 2 rows) WITH pagination
« previous next »
Pages: [1] Print
Instabuck - The easy way to sell digital products online

Author 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.
Evil
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5799
46391 credits
Members referred : 3



« Reply #1 on: Feb 10, 2008, 09:54:06 am »

Can you give a part of your code?

Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #2 on: Feb 10, 2008, 10:01:42 am »

something like this?
http://www.finalwebsites.com/demos/php_mysql_nested_repeat_region.php

you can use this together with this snippet:
http://www.finalwebsites.com/snippets.php?id=37

but next you shpuld show us you page we don't provide the solution because you're just asking Wink

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!:

Code:
<html>
<head>
<title>Pagination Example</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<?php
include 'library/config.php';
include 
'library/opendb.php';

// how many rows to show per page
$rowsPerPage 5;

// by default we show first page
$pageNum 1;

// if $_GET['page'] defined, use it as page number
if(isset($_GET['page']))
{
$pageNum $_GET['page'];
}

// counting the offset
$offset = ($pageNum 1) * $rowsPerPage;

$query  "SELECT ProductID, ProductName, BuyURL, ImageURL, Price FROM Products";
   
$pagingQuery 
"LIMIT $offset$rowsPerPage";
$result mysql_query($query $pagingQuery) or die('Error, query failed');

// print the student info in table
echo '<table border="0">';
// Student Id</td></tr><TR><td>Name</td></tr><TR><td>Address</td></tr><TR><td>Age</td></tr><TR><td>Register Date</td></tr>';
while(list($ProductID$ProductName$BuyURL$ImageURL$Price) = mysql_fetch_array($result))
{
echo "<TR width='100' hieght='100'><TD >";
echo 
"<a href=\"" $BuyURL "\">
<img src=\"" 
$ImageURL"\" border=0 alt=\"" $ProductName"\">
</a>" 
;
echo "<tr><td>$ProductID</td></tr><TR><td>$Price</td></tr>";
}
echo 
'</table>';
echo 
'<br><BR>';

// 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: Male
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



« Reply #5 on: Dec 10, 2008, 01:59:42 pm »

Your mean like this?
Code:
<?php
echo '<table><tr>';
while(...){
    if($n%== && (data is not first)) echo '</tr><tr>';
    else echo '<td>',$data,'</td>';
}
echo 
'</tr></table>';
?>

« Last Edit: Dec 10, 2008, 02:03:05 pm by linvo »
Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=7584
Tags : pagination fomating sql data Bookmark this thread : Digg Del.icio.us Dzone more....

Pages: [1] Print 
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: Display results in a 4x2 display (4 columns, 2 rows) WITH pagination
« previous next »
Jump to:
User Area
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 29, 2012, 12:45:50 am





Login with username, password and session length

Donate to our community, and get a permanent link back to your site!

Donate to our community, and get a permanent link back to your site!






Web Design Gallery · Whois Lookup · Pagerank · Tag Browsing · Lo-fi version · Syndication · Webmaster forum history · Advertise
Developed by HumanWorks © 2005 - 2012 Webdigity webmaster community · sublime directory
Webdigity Webmaster Forums | Powered by SMF 1.0.12. © 2001-2005, Lewis Media. All Rights Reserved.