Portal Home > Knowledgebase > Articles Database > PHP/PEAR/MYSQL Loop Results?


PHP/PEAR/MYSQL Loop Results?




Posted by pwalters09, 02-09-2010, 11:48 PM
Hi guys, Basically I am a bit of a noob when it comes to PEAR, and am wondering if anyone can help... Basically what I need to do is query my database, then loop the results into a select box... I need to select 2 fields from a database that match query, then loop the results (like mysql_fetch_assoc() but with pear) Here is my code: Can anyone help? Thanks

Posted by Driver01, 02-10-2010, 08:25 AM
Is this not working for you at the moment? Sorry for the obvious question but what exactly is the problem at the moment? Last edited by Driver01; 02-10-2010 at 08:37 AM.

Posted by pwalters09, 02-10-2010, 09:10 AM
No for some reason I keep getting a 'call to a member function in a non-member object' errors when trying to do it.

Posted by Driver01, 02-10-2010, 09:51 AM
are all the required files included?

Posted by pwalters09, 02-10-2010, 10:22 AM
yes everything required (db connection script etc) included in the main php script.

Posted by Driver01, 02-10-2010, 11:33 AM
query = $this->db->query($qry); Last edited by Driver01; 02-10-2010 at 11:37 AM.

Posted by pwalters09, 02-10-2010, 12:03 PM
that just fetches 1 result doesnt it? i need to loop the results

Posted by Driver01, 02-10-2010, 12:11 PM
No the while loop on the query and the fetchInto function should return as many results as you have, I am just trying to find out what the non-object is reffering too, I am presuming its $db_object. What is the whole error?



Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read
ValueWeb is down (Views: 809)
FDC offline? (Views: 747)
VPS on a VPS (Views: 631)

Language: