![]() |
Split results into 2 columns
I have the following code:
Code:
$result = mysql_query("SELECT * from patterns WHERE cattxt = 'Wreaths' ORDER BY dsptxt"); |
PHP Code:
|
Quote:
|
Something like the following although I'm unable to test it currently.
PHP Code:
You might end up with a blank row, so it needs a little more work. Added: to get around this you could, instead, create a string and check what occurs at the end of this string - and amend it accordingly. |
Quote:
This does exactly what I want it to do....add the table width of 100% in there so it spaces the table out through the whole screen and it is perfect! The only oddity is I have 2 links at the very top showing out of alphabetical order, but it may be a problem with how they were entered in the database. |
If you prefer the data to go down the first column, before continuing in a second column, you would need to:
Count how many records there are; Half this value; Store the td's in two separate arrays (for odd and even indexes); Use, perhaps, array_map, to construct a single string from the two arrays; Echo the resultant string. |
Quote:
|
No worries :thumbsup:
I would check the resultant table (View Source) to make sure that the HTML is not malformed; but I suppose having an additional empty row is not too worrying - it will collapse anyway. Andy. |
Quote:
|
| All times are GMT +1. The time now is 04:42 AM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.