How to display data horizontaly?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
charli18
Forum Newbie
Posts: 11
Joined: Tue May 19, 2009 3:35 am

How to display data horizontaly?

Post by charli18 »

Hi,
Could anyone please tell me how to display data horizontaly with limited 2 products for each row?

Thanks
User avatar
jaoudestudios
DevNet Resident
Posts: 1483
Joined: Wed Jun 18, 2008 8:32 am
Location: Surrey

Re: How to display data horizontaly?

Post by jaoudestudios »

Can you give a simple example of what you mean?
charli18
Forum Newbie
Posts: 11
Joined: Tue May 19, 2009 3:35 am

Re: How to display data horizontaly?

Post by charli18 »

For example we have a page that display images from a database but in horizontal.

Like below:


Image1 :D Image2 :D


Image 3 :D Image 4 :D
User avatar
jaoudestudios
DevNet Resident
Posts: 1483
Joined: Wed Jun 18, 2008 8:32 am
Location: Surrey

Re: How to display data horizontaly?

Post by jaoudestudios »

What html are you using? tables/lists?
charli18
Forum Newbie
Posts: 11
Joined: Tue May 19, 2009 3:35 am

Re: How to display data horizontaly?

Post by charli18 »

table
User avatar
jaoudestudios
DevNet Resident
Posts: 1483
Joined: Wed Jun 18, 2008 8:32 am
Location: Surrey

Re: How to display data horizontaly?

Post by jaoudestudios »

Code: Select all

 
<table>
   <tr>
      <td>1</td>
      <td>2</td>
  </tr>
   <tr>
      <td>3</td>
      <td>4</td>
  </tr>
</table>
 
Last edited by Benjamin on Thu May 21, 2009 8:44 am, edited 1 time in total.
Reason: Changed code type from text to html.
charli18
Forum Newbie
Posts: 11
Joined: Tue May 19, 2009 3:35 am

Re: How to display data horizontaly?

Post by charli18 »

I did not ask for HTML.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: How to display data horizontaly?

Post by Benjamin »

charli18 wrote:Hi,
Could anyone please tell me how to display data horizontaly with limited 2 products for each row?

Thanks
Looks like your question was answered.
User avatar
jayshields
DevNet Resident
Posts: 1912
Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England

Re: How to display data horizontaly?

Post by jayshields »

The OP worded the original question badly, but what he wants is automatic table generation.

You need a counter which increments for each piece of data, and when the counter is an even number (eg. $counter % 2 == 0) then end the current row and start a new one.
Post Reply