Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Display results in a table.. 4 columns?
Old 06-22-2005, 05:27 PM Display results in a table.. 4 columns?
Unknown.

Posts: 1,693
Trades: 0
What I want to be able to do is select the results from the database and then display them in a table with four columns.. for example..
HTML Code:
<table border>
<tr>
<td width="100">Result 1</td>
<td width="100">Result 2</td>
<td width="100">Result 3</td>
<td width="100">Result 4</td>
</tr>
</table>
But also only display 4 rows per page and then have links to go to the next and previous pages which will display another 16 results (4 rows x 4 columns)

So if anyone could point me towards a tutorial or provide the coding that would be great!

Thanks
Dark-Skys99 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-24-2005, 09:51 AM
Unknown.

Posts: 1,693
Trades: 0
Anyone?

If you need any more information just ask.

Thanks!

Last edited by Dark-Skys99; 06-06-2006 at 09:16 AM..
Dark-Skys99 is offline
Reply With Quote
View Public Profile
 
Old 06-24-2005, 10:49 AM
desertland's Avatar
Skilled Talker

Posts: 86
Trades: 0
I assume you're using a scripting language like PHP or Perl to accomplish this?

When MySQL 4+, you can use "select sql_calc_found_rows, field1, field2..." where 'sql_calc_found_rows' lets you make another query ("select found_rows()") that returns the total number of rows.

So what you have to do is select the data you want, and then have a "limit" statement at the end of your query - for example, "limit $offset, 4". The $offset is by default set to 0. If you find out that the total # of rows that would have been returned (without the limit - you get this from the 'found_rows()' query) is greater than 4, then you need to print a "Next" link where you increment the $offset variable by 4. So, the first time the query is run, the limit statement will be "limit 0, 4" (select the first 4 rows). When someone clicks on 'next', it will be "limit 4, 4" (select rows 5-8).

For previous, just check of $offset is greater than 0. If it is, print a "Previous" link that sets $offset to $offset - 4;

Good luck!
__________________
I store my recipes online (the way nature intended) at
Please login or register to view this content. Registration is FREE
desertland is offline
Reply With Quote
View Public Profile
 
Old 06-24-2005, 01:38 PM
Unknown.

Posts: 1,693
Trades: 0
Thanks, although I pretty much have the pagination sorted. All I really need to know is how to display the results in the four columns.. Although I've decided to do it a different way now but if anyone can help with putting the results into the columns that would hlp for the future.

Thanks!
Dark-Skys99 is offline
Reply With Quote
View Public Profile
 
Old 06-24-2005, 06:21 PM
metho's Avatar
Ultra Talker

Posts: 481
Location: Gold Coast - Brisbane QLD, Australia
Trades: 0
This tutorial will get you sorted: LINK.
__________________
I do
Please login or register to view this content. Registration is FREE
based.
Spend a lot of time in
Please login or register to view this content. Registration is FREE
.
And
Please login or register to view this content. Registration is FREE
chews up the rest.
metho is offline
Reply With Quote
View Public Profile Visit metho's homepage!
 
Reply     « Reply to Display results in a table.. 4 columns?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.21323 seconds with 12 queries