|
Posted by Erwin Moller on 04/06/07 15:33
leader@congress.hotmail.com wrote:
> I'm trying to list meteorological data reports, from an ever-varying
> number of locations, in two columns, side-by-side - the first half of
> the list alphabetically in the left column and then the second half in
> the right column. In the example below, numbering the locations for
> the purpose of the example, it has to be something like this, using,
> say, 60 locations -
>
> $Query="SELECT * FROM obervations order by location";
> $Result=mysql_db_query ($DBName, $Query, $Link);
> while ($Row=mysql_fetch_array ($Result))
> (
>
> <table>
> <tr>
> <td>$Row[location1] $Row[humidity1] $Row[oktas1]</td>
> <td>$Row[location31] $Row[humidity31] $Row[oktas31]</td>
> </tr>
> <tr>
> <td>$Row[location2] $Row[humidity2] $Row[oktas2]</td>
> <td>$Row[location32] $Row[humidity32] $Row[oktas32]</td>
> </tr>
> </table>
>
>
> and so on until the database is exhausted.
> I've tried using arrays to store each data item but I think it's
> clumsy. Is there a more elegant way to do it?
> TIA.
Why is that clumsy?
But another thought could be:
Rebuild your html so it contains a outer table.
<table>
<tr>
<td>
<table>
.. first 30 results go here
</table>
</td>
<td>
<table>
.. next 30 results go here
</table>
</td>
</tr>
</table>
That way you only have to find the middle one and let php spit out the
</table>
</td>
<td>
<table>
part, and you can 'normally' traverse through your results from the
database.
But putting things in an array first is not clumsy, unless you have such a
huge amount of data you get into resourcestrouble (eg the 8MB default PHP
memory allocation)
Regards,
Erwin Moller
Navigation:
[Reply to this message]
|