Current location: Hot Scripts Forums » Programming Languages » PHP » How to Display Data in Columns


How to Display Data in Columns

Reply
  #1 (permalink)  
Old 02-16-06, 07:17 PM
php-learner php-learner is offline
Newbie Coder
 
Join Date: Jan 2004
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Unhappy How to Display Data in Columns

Help!!!

I am completely baffled...

I know how to display data in rows etc, what i would really like to do is display data in columns say 3 columns per row and display the results down the page etc. I have tried other sites and tutorials but i just can not get anywhere.

Could any one point me in the right direction please. I would also like to style the columns for example: If i am displaying data with an image for a sub category i would like to place a css style oultline around this and then obviously repeat the pricess for the other categories.

Thanks in advance

php-learner
Reply With Quote
  #2 (permalink)  
Old 02-16-06, 11:18 PM
nekeno12 nekeno12 is offline
Wannabe Coder
 
Join Date: May 2004
Location: CO
Posts: 214
Thanks: 0
Thanked 0 Times in 0 Posts
I always use while()

if you're dealing with a mysql result for example:

PHP Code:

<?php
while ($result mysql_fetch_assoc($query)) {
?>
<tr>
   <td><?=$result['value']?></td>
</tr>
<?php
}
?>

This will get you started at least.
Reply With Quote
  #3 (permalink)  
Old 02-17-06, 02:22 AM
steveo steveo is offline
Wannabe Coder
 
Join Date: Jun 2004
Posts: 130
Thanks: 0
Thanked 0 Times in 0 Posts
This would be three rows, and three coloums.

Code:
<table width="100%" border="0">
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>
All you would need to do is create some count function to count up to 2 or 3, and each time it is, it's echoing the new <td></td>'s. After the count hit's to three, an if statement changes the code to echo only </tr><tr> and reset the counter back to 0. Have fun, try experiment.
Reply With Quote
  #4 (permalink)  
Old 02-17-06, 03:45 AM
php-learner php-learner is offline
Newbie Coder
 
Join Date: Jan 2004
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Wink

Thanks for your quick responses. I will give this a go straight away.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
display mysql data in columns? todayscoffee PHP 4 03-11-09 10:05 PM
Php Form + mysql + display data sent needed TheRaider Script Requests 3 10-07-04 01:30 AM
Is it possible to put dynamic data display in a scrolling watermark? Whipsmack JavaScript 1 03-29-04 08:22 AM
cannot display the complete data najmun PHP 2 07-04-03 02:52 PM


All times are GMT -5. The time now is 06:34 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.