Results 1 to 2 of 2
-
03-17-2006, 06:24 AM #1WHT Addict
- Join Date
- Jan 2002
- Location
- London UK
- Posts
- 142
code snippet - building vertical columns from a mysql result
Code:$result = mysql_query("SELECT * FROM cities ORDER BY city_name") or die ("Failed.".mysql_error()); $num_rows = mysql_num_rows($result); $x = 0; $num_cols = 4; print ' <TABLE CELLPADDING="0" CELLSPACING="0" BORDER="0" WIDTH="100%"> <TR> <TD VALIGN="TOP">'; while($row = mysql_fetch_array($result)) { print $row['city_name']. '<BR>'; $x++; if ($x == ceil($num_rows / $num_cols)) { print ' </TD> <TD VALIGN="TOP">'; $x = 0; } } print ' </TD> </TR> </TABLE>';
Philco
-
09-16-2006, 03:12 PM #2Newbie
- Join Date
- Sep 2006
- Posts
- 12
thanks ive been loking for something like this for my uncles site, hel be happy in the morning when i give him a link to the site