General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old January 8th, 2004, 04:04 AM
teddyfrost teddyfrost is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 3 teddyfrost User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
How do I display records horizontally?

Hi there,

I want to create a system which will display 4/5 fields from a record vertically using new rows for each field as normal.
But then i want the records to display horizontally, with a limit of 4 records per row.

Since there are kind of two row references (one for the rows containing the fields of the indivual record, and another to contain the completed records four at a time) it confusing me.

I have found previous messages relating to displaying records horizontally, but non seem to include using multiple fields, and displaying these vertically, within the horizontal layout.

Im presuming i have to use some kind of nestled loop but i cant figure out how to do it.

Essentially i need to create a new row, then loop 1-4 through the records for the first field, then do a new row, loop 1-4 for field 2 and continue till ive got all four fields done.
Then i guess i have to include some kind of modulus function to start new rows of rows (this is causing problems in itself)

Do i need to use tables and rows rather than rows and tds because i have one more step than normal horizontal display? (i think)

Any help would be greatly appreciated

Reply With Quote
  #2  
Old January 8th, 2004, 07:46 AM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
I think your final conclusion is about right, though I'm having difficulty understanding precisely what it is you're trying to do. Based on my loose understanding, it sounds like nested tables might do the trick.

Reply With Quote
  #3  
Old January 8th, 2004, 08:06 AM
teddyfrost teddyfrost is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 3 teddyfrost User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
ok, Heres some more details.

I have a table (members) with details such as name, image_url, email_address etc

I want to display each record like this (pseudo code)

<tr>
<td>image url</td>
</tr>
<tr>
name
</tr>
<tr>
email_address
</tr>

This is so the info it displayed in one column.

The problem is, that when the next record is parsed, it actually needs to insert a second <td> into each of the already existing rows.
This needs to happen untill each of the rows above has 4 <td>'s in it (thats the number i want in each line)

THEN...i need to start a new row with the records 5-8 in it, 3rd row 9-12 etc

Does this make it any clearer?

Reply With Quote
  #4  
Old January 8th, 2004, 08:58 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 14 m 9 sec
Reputation Power: 8
Have you drawn it out on paper?
i find that helps sometimes when dealing with tables/columns/rows...

Based on the example you've given, it sounds to me you want something like this:

<table>
<tr>
<td>image1</td>
<td>image2</td>
<td>image3</td>
</tr>
<tr>
<td>name1</td>
<td>name2</td>
<td>name3</td>
</tr>
<tr>
<td>email_address1</td>
<td>email_address2</td>
<td>email_address3</td>
</tr>
</table>


In which case, you were right about the modulus...

Assuming every record contains three peices of data (like in this example), your entire table will be divisible by three...

Giving each peice of data a sequential number may help (as a cell reference)... try the following in an html document:

<table>
<tr>
<td>1. image1</td>
<td>4. image2</td>
<td>7. image3</td>
</tr>
<tr>
<td>2. name1</td>
<td>5. name2</td>
<td>8. name3</td>
</tr>
<tr>
<td>3. email_address1</td>
<td>6. email_address2</td>
<td>9. email_address3</td>
</tr>
</table>


Look for the relation between the guidance numbers (1 through 9)... now remember hte use of modulus...

Hopefully this helps... =)

Reply With Quote
  #5  
Old January 8th, 2004, 09:10 AM
teddyfrost teddyfrost is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 3 teddyfrost User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
yeah thats kinda the thing im trying to do.

I was following an example of how to do horizontal rows and managed to get it working with just one field, and i assumed i would be able to use nestled loops as shown below

PHP Code:
 $cells 0;
$cells2 0;
do{
echo 
"<TD width='25%' height='131' valign='top'>$item[id]</TD>";

if(!(
$cells 4))
{
do{
echo 
"<TD width='25%' height='25' valign='top'>$item[clan_nick]</TD>";

if(!(
$cells2 4))
{
echo 
"</tr><tr>";
}
$cells2++;
} while (!(
$cells2 4));
}
$cells++;
} while (
$item mysql_fetch_array($sql)); 


This doesnt seem to work, it simply lists all the ids on one row - any ideas if theres anything fundimentally wrong here?
Bearing in mind it works it you remove the inner loop

Reply With Quote
  #6  
Old January 8th, 2004, 11:39 AM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
If you don't mind looping through the data twice, you could use mods to build arrays that position the data by index and then loop through the arrays to print stuff out in the right slots.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > How do I display records horizontally?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT