NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page Help: Loop over query result

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search
5 members in live chat ~  


Reply
 
LinkBack Thread Tools
Old 12-19-2010, 02:18 PM THREAD STARTER               #1 (permalink)
Ik
Quality //
Join Date: Sep 2008
Posts: 911
Ik has much to be proud ofIk has much to be proud ofIk has much to be proud ofIk has much to be proud ofIk has much to be proud ofIk has much to be proud ofIk has much to be proud ofIk has much to be proud ofIk has much to be proud of
 


Breast Cancer Save a Life Alzheimer's Wildlife Wildlife

Help! Help: Loop over query result


Hi,

Please help me with this.

http://mbe.ro/2009/08/30/fast-and-easy-php-mysql-class/

Code Line 129 //method to select (clean and beautiful)

The author has put a sample result, but I just don't know how to loop over the results to display the records on my PHP page.

Pls help
Thanks
Ik is offline   Reply With Quote
Old 12-20-2010, 01:12 PM   #2 (permalink)
Senior Member
 
nasaboy007's Avatar
Join Date: Jul 2005
Location: NJ
Posts: 1,219
nasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud of
 



looks like its just a nested array. use the foreach() loop (nested) to pull out the data.
nasaboy007 is offline   Reply With Quote
Old 12-21-2010, 05:15 PM   #3 (permalink)
NamePros Regular
 
baxter's Avatar
Join Date: Apr 2006
Posts: 360
baxter is just really nicebaxter is just really nicebaxter is just really nicebaxter is just really nice
 


Ethan Allen Fund Save The Children
given the example it would be:

Code:
//method to select (clean and beautiful)
$result = $m->select(array(
	'table' => 'users',
	'condition' => 'active=1 AND type=1'
));

foreach ($result as $row) {
   //The data is in $row['user'] where user is the mysql table name
   //so if there was a field username you would retrieve it like this
   $username = $row['user']['username'];
}
__________________
Canadian Domain Registrar Ready.ca
baxter is offline   Reply With Quote
Old 12-22-2010, 03:46 AM THREAD STARTER               #4 (permalink)
Ik
Quality //
Join Date: Sep 2008
Posts: 911
Ik has much to be proud ofIk has much to be proud ofIk has much to be proud ofIk has much to be proud ofIk has much to be proud ofIk has much to be proud ofIk has much to be proud ofIk has much to be proud ofIk has much to be proud of
 


Breast Cancer Save a Life Alzheimer's Wildlife Wildlife
It works. Thank you

Originally Posted by baxter View Post
given the example it would be:

Code:
//method to select (clean and beautiful)
$result = $m->select(array(
	'table' => 'users',
	'condition' => 'active=1 AND type=1'
));

foreach ($result as $row) {
   //The data is in $row['user'] where user is the mysql table name
   //so if there was a field username you would retrieve it like this
   $username = $row['user']['username'];
}
Ik is offline   Reply With Quote
Old 12-24-2010, 10:20 PM   #5 (permalink)
NamePros Member
Join Date: Nov 2010
Posts: 34
pausch is an unknown quantity at this point
 



Thanks the code is working with me.
pausch is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to do a diff query for each value in a loop DJ-Sound Programming 5 10-19-2009 03:05 PM
overture question Scorpio Domain Newbies 2 09-25-2004 07:04 AM
Great Domain Typo Generator Script jaydons Scripts For Sale 2 08-20-2004 06:19 AM
Domain Typo Script jaydons Scripts For Sale 8 08-08-2004 10:49 AM

 
All times are GMT -7. The time now is 02:42 PM.

Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger