By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,264 Members | 1,056 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,264 IT Pros & Developers. It's quick & easy.

Set table width

P: n/a
Hi,

I am new with php. I need to loop through some variables and place
them in 3 columns. I couldn't align the header line and each result
line. How do I make the table in uniform size in each column? And how
do I wrap to new line if one of the variable is too long?
Thanks in advance.
Jul 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
On 2003-12-08, xo55ox <xo****@hotmail.com> wrote:
Hi,

I am new with php. I need to loop through some variables and place
them in 3 columns. I couldn't align the header line and each result
line. How do I make the table in uniform size in each column? And how
do I wrap to new line if one of the variable is too long?


This is a HTML question meaning there are better for these questions.

(the text in a column is auto-wrapped, so you don't need to break up the
lines yourself)

--
verum ipsum factum
Jul 17 '05 #2

P: n/a
I noticed that Message-ID:
<br*************@ID-188825.news.uni-berlin.de> from Tim Van Wassenhove
contained the following:
I am new with php. I need to loop through some variables and place
them in 3 columns. I couldn't align the header line and each result
line. How do I make the table in uniform size in each column? And how
do I wrap to new line if one of the variable is too long?


This is a HTML question meaning there are better for these questions.


But he needs to know how to write the php to give him three columns. I
use a counter and use the modular operator to find the remainder when
divided by three. Then a simple if statement is used to either finish
the row or continue it.

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #3

P: n/a
On 2003-12-08, Geoff Berrow <bl******@ckdog.co.uk> wrote:
I noticed that Message-ID:
<br*************@ID-188825.news.uni-berlin.de> from Tim Van Wassenhove
contained the following:
I am new with php. I need to loop through some variables and place
them in 3 columns. I couldn't align the header line and each result
line. How do I make the table in uniform size in each column? And how
do I wrap to new line if one of the variable is too long?


This is a HTML question meaning there are better for these questions.


But he needs to know how to write the php to give him three columns. I
use a counter and use the modular operator to find the remainder when
divided by three. Then a simple if statement is used to either finish
the row or continue it.


Sorry, i misunderstood the question.

If he's going to fill the tables

1 2 3
4 5 6
7 8 9

then it's more efficient to use a counter, without modular operator.

while (data available) {
$counter = 0;
echo "<tr>";
while (data available && $counter < $columns) {
echo "<td></td>";
$counter++;
}
echo "</tr>";
}

Filling the tables as
1 4 7
2 5 8
3 6 9

He should first determine the number of rows ($rownum = #data / # columns wanted)
and then make rows as
<tr><td>$counter+0*$rows</tid><td>$counter+1*$rows</td><td>$cnt+2*$row</td></tr>
(Off course this can be optimised, as $rows is known.)

--
verum ipsum factum
Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.