User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 422,410 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 5,017 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 328 | Replies: 4
Reply
Join Date: Dec 2007
Posts: 14
Reputation: webguru07 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 1
webguru07 webguru07 is offline Offline
Newbie Poster

table rows and columns

  #1  
May 18th, 2008
Hi,

I need to display 4 items from a MySQL database in a 2x2 table (2 columns, 2 rows) i know how display just rows and columns, but how would I do both?

thank you
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jan 2008
Posts: 37
Reputation: robothy is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 6
robothy robothy is offline Offline
Light Poster

Re: table rows and columns

  #2  
May 18th, 2008
Have you considered using embedded for loops?
Reply With Quote  
Join Date: Dec 2007
Posts: 14
Reputation: webguru07 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 1
webguru07 webguru07 is offline Offline
Newbie Poster

Re: table rows and columns

  #3  
May 18th, 2008
Originally Posted by robothy View Post
Have you considered using embedded for loops?


could you give me an example please?
Reply With Quote  
Join Date: Aug 2007
Location: Cavite,Philippines
Posts: 508
Reputation: ryan_vietnow is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 68
ryan_vietnow's Avatar
ryan_vietnow ryan_vietnow is offline Offline
Posting Pro

Re: table rows and columns

  #4  
May 18th, 2008
please specify the fields you want to display in the table.
"death is the cure of all diseases..."
http://ryantetek.wordpress.com
Reply With Quote  
Join Date: Jan 2008
Posts: 37
Reputation: robothy is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 6
robothy robothy is offline Offline
Light Poster

Re: table rows and columns

  #5  
May 19th, 2008
$strHtml = '<table class="blah">';
$intCount = 0;
for($i = 0; $i < 2; $i++) {
$strHtml .= '<tr>';
for($j = 0; $j < 2; $j++) {
$strHtml .= "<td>{$arrResult[$intCount]}</td>";
$intCount++;
}
$strHtml .= '</tr>';
}
$strHtml .= '</table>';


That is a very untidy example. I never usually mix HTML and PHP, so to better the above, I would be inclined to template it and have a separate template for each table cell. But that should be enough to work with and improve upon.

R.
Last edited by robothy : May 19th, 2008 at 2:48 am.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb PHP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 9:24 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC