Top 10 Daily Top Selling Deals - Official TigerDirect.com Deals

Official TigerDirect.com Coupons

Official TigerDirect.com Coupons

Tuesday, March 1, 2011

Recursive DB access question.


Hi

I'm fairly new to this forum, no issue as such with DB connections to MySQL from PHP, but I find I need to recurse through a hierachy tree,

Im issue is how do I set up a query within the result set of an already open query, or how do I build an array of results that I can access once the query is closed.

MY experience of Linux/Unix os high, perl is good, Oracle and MySQL good, PHP getting there.

Any pointers appreciated, if I had access to MySQL 5.x I could do this with a stored procedure, but I' currenly stuck with MySQL 4.x supplied by my hosting provider.

my current query method is:

<?php
mysql_connect("localhost", "fred", "Fred1234") or die(mysql_error());
#echo "Connection to the server was successful!<br/>";
mysql_select_db("Fredsdb") or die(mysql_error());
#echo "Database was selected!<br/>";

$result = mysql_query("SELECT m.position, m.link, m.name FROM menu m where m.menu_grp in ($group_id) and m.active = 1 order by m.menu_grp, m.position");

while ($row = mysql_fetch_assoc($result)) {

#do what ever needs doing.

}

?>


Rob.

No comments:

Post a Comment

Computers-and-Technology Articles from EzineArticles.com