Print Table - Left To Right

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
User avatar
tmaiden
Forum Commoner
Posts: 64
Joined: Fri Feb 24, 2006 3:15 pm
Location: Philadelphia
Contact:

Print Table - Left To Right

Post by tmaiden »

My site currently has a table on it where information is filled into cells. These cells go left to right, then top to bottom.

SORRY FOR THE ASCII ART, ONLY WAY I COULD EXPLAIN

Example: r = row, c = column

Code: Select all

[r1c1][r1c2][r1c3][r1c4][r1c5][r1c6][r1c7]
[r2c1][r2c2][r2c3][r2c4][r2c5][r2c6][r2c7]
I am trying to print the same information now like this.
Example: r = row, f = field, SC = Seperating Column

Code: Select all

________        ____  _________
|        |[r1f2]|    ||         |[r2f2] 
| r1f1   |[r1f3]|    || r2f1    |[r2f3] 
|        |[r1f3]| SC ||         |[r2f3] 
|        |[r1f4]|    ||         |[r2f4] 
|________|[r1f5]|    ||_________|[r2f5] 
[ r1f6   ][r1f7]|____|[ r2f6    ][r2f7]
Here is the html for the above

Code: Select all

<HTML>
<BODY>
	<TABLE CELLSPACING=0 WIDTH=400>
		<TR>
			<TD ROWSPAN=4>r1f1</TD>
			<TD>r1f2</TD>
			<TD ROWSPAN=5></TD>
			<TD ROWSPAN=4>r2f1</TD>
			<TD>r2f2</TD>
		</TR>
		<TR>
			<TD>r1f3</TD>
			<TD>r2f3</TD>
		</TR>
		<TR>
			<TD>r1f4</TD>
			<TD>r2f4</TD>
		</TR>
		<TR>
			<TD>r1f5</TD>
			<TD>r2f5</TD>
		</TR>
		<TR>
			<TD>r1f6</TD>
			<TD>r1f7</TD>
			<TD>r2f6</TD>
			<TD>r2f7</TD>
		</TR>
	</TABLE>
</BODY>
</HTML>

Any help on how I can loop through my data and put it in its corrisponding cell would be greatly appricated. Note: Both tables are examples of 2 rows, when infact i need this to be generated dynamically since in other cases, more rows are needed.

Thanks!
[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1 wrote:1. Select the correct board for your query. Take some time to read the guidelines in the sticky topic.
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

you'll have to do some nested loops and use some conditionals to print out the correct row / column info
User avatar
Trenchant
Forum Contributor
Posts: 291
Joined: Mon Nov 29, 2004 6:04 pm
Location: Web Dummy IS

Post by Trenchant »

Not sure if this would work(depending on whether there was a set number of results or not). What about throwing the informatino in an array? Say you had 5 columns so you create 5 arrays and assign each value to an index number. That way you can collect the data and output it all at once.

If the table doesn't need to be completely dynamic that should work.
User avatar
tmaiden
Forum Commoner
Posts: 64
Joined: Fri Feb 24, 2006 3:15 pm
Location: Philadelphia
Contact:

Post by tmaiden »

Hmm, all good ideas. Might do nested loops within nested tables. Too tired atm to write the 50 loops; I'll give it a shot though when I have the chance and post the outcome.

Thanks again!
Post Reply