hosted by liquidweb

Go Back   Web Hosting Talk : Web Hosting Main Forums : Web Hosting Talk Tutorials : Programming Tutorials : code snippet - building vertical columns from a mysql result

Forum Jump

code snippet - building vertical columns from a mysql result

Reply Post New Thread In Programming Tutorials Subscription
Send news tip View All Posts Thread Tools Search this Thread Display Modes
WHT Addict
Join Date: Jan 2002
Location: London UK
Posts: 140

code snippet - building vertical columns from a mysql result

$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 '
	while($row = mysql_fetch_array($result)) { 

		print $row['city_name']. '<BR>';


		if ($x == ceil($num_rows / $num_cols)) {

			print '
			<TD VALIGN="TOP">';

			$x = 0;


	print '
$num_cols is the number of columns you want....


Sponsored Links
Join Date: Sep 2006
Posts: 8
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


Related posts from
Title Type Date Posted
CloudLinux Releases Software for Web Hosts to Set Limits on Accounts Running MySQL Web Hosting News 2015-01-26 14:42:26
Tesora's OpenStack DBaaS Supports MongoDB, Cassandra, Redis, and MySQL Web Hosting News 2014-05-23 14:53:11
Google Releases Hosted Database Service Cloud SQL to General Availability Web Hosting News 2014-02-12 13:46:02
Google Cloud Provides Support For Native MySQL Connections Web Hosting News 2013-11-01 14:36:06
Hackers Pack More Sophistication into Simple Scripts to Attack PHP Applications Web Hosting News 2013-09-09 11:52:48

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump
Log in with your username and password

Forgot Password?
WHT Host Brief Email:

We respect your privacy. We will never sell, rent, or give away your address to any outside party, ever.

Web Hosting News:
WHT Membership
WHT Membership



Welcome to

Create your username to jump into the discussion! is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.

(4 digit year)

Already a member?