/    Sign up×
Community /Pin to ProfileBookmark

Variable number of rows….

I am running a PHP program against my database to pull out a variable number of rows – sometimes none, sometimes 15.

I want to display 4 of the fields in my page in rows, but I want the rows to line up in 4 columns. The fields are ID, Name, Contact and URL. So I want all the IDs in line down the page, and all the Names etc etc.

I could do this with a table, but I don’t think it is the right way to go.

I’m not sure how to do this with CSS, because you can only get one row at a time so you have to place it on the page then get the next row and so on.

For those who don’t know PHP, I can output each field individually and surround the value with any HTML or CSS that I need.

Can anyone give me a hint as to how to set up my CLASS and whether to use DIVs for the rows or columns or both.

Thanks

to post a comment
CSS

1 Comments(s)

Copy linkTweet thisAlerts:
@StefanDec 01.2002 — [i]Originally posted by Rodders [/i]

I could do this with a table, but I don't think it is the right way to go.
[/QUOTE]


I don't know.

Sound to me like you want to present tabular data on your page in a nice row/colum order.

That is exactly what <table> is meant to do.


Can anyone give me a hint as to how to set up my CLASS and whether to use DIVs for the rows or columns or both.
[/QUOTE]


Well you could do something like

<div id="row1">

<div class="col1"></div>

<div class="col2"></div>

<div class="col3"></div>

<div class="col4"></div>

</div>

With width and float:left specified for col1-4, but as I already said, you probably should use <table> for this.
×

Success!

Help @Rodders spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...