Help: Loop over query result

Namecheap AuctionsNamecheap Auctions
Namecheap AuctionsNamecheap Auctions
SpaceshipSpaceship
Watch

Ik

Quality //VIP Member
Impact
8
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
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
looks like its just a nested array. use the foreach() loop (nested) to pull out the data.
 
0
•••
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'];
}
 
0
•••
It works. Thank you :)

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'];
}
 
0
•••
Thanks the code is working with me.
 
0
•••
Appraise.net

We're social

Escrow.com
Spaceship
Escrowly
CryptoExchange.com
Domain Recover
URLs.com
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back