Variable number of rows....

windows

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

ThanksOriginally posted by Rodders

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


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.


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.
 
Back
Top