hosted by liquidweb


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

Programming Tutorials How-Tos related to programming, databases, and the like.
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
  #1  
Old 03-17-2006, 06:24 AM
Philco Philco is offline
WHT Addict
 
Join Date: Jan 2002
Location: London UK
Posts: 139

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>';
$num_cols is the number of columns you want....

Philco

Reply With Quote


Sponsored Links
  #2  
Old 09-16-2006, 03:12 PM
welshboy welshboy is offline
Newbie
 
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

Reply With Quote
Reply

Related posts from TheWhir.com
Title Type Date Posted
Web Hosting Sales and Promos Roundup – February 8, 2013 Web Hosting News 2013-02-08 16:47:52
Web Hosting Sales and Promos Roundup – April 27, 2012 Web Hosting News 2012-04-27 16:32:30
WebsPlanet Offers Eclipse Website Building Software for Web Hosts, teams with Ecommerce Tool Ecwid Web Hosting News 2012-03-19 22:53:11
Web Host Rackspace Launches Private Beta for MySQL Cloud Database Web Hosting News 2011-12-01 21:09:51
Jelastic Java PaaS Service Now Enables App Building in the Cloud Web Hosting News 2011-11-18 16:57:16


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 On
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com 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?