954,568 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

table rows and columns

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

webguru07
Newbie Poster
14 posts since Dec 2007
Reputation Points: 10
Solved Threads: 1
 

Have you considered using embedded for loops?

blocblue
Posting Pro in Training
475 posts since Jan 2008
Reputation Points: 142
Solved Threads: 79
 
Have you considered using embedded for loops?

could you give me an example please?

webguru07
Newbie Poster
14 posts since Dec 2007
Reputation Points: 10
Solved Threads: 1
 

please specify the fields you want to display in the table.

ryan_vietnow
Posting Pro
578 posts since Aug 2007
Reputation Points: 28
Solved Threads: 71
 

$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.

blocblue
Posting Pro in Training
475 posts since Jan 2008
Reputation Points: 142
Solved Threads: 79
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You