So I'm trying to write a recursive function that goes through a mySQL database and prints out a bunch of things (it's basically a tree-style support system). Here's my code for the recursive function:
function printOut($myResult) {
while ($theRow = mysql_fetch_array($myResult,MYSQL_ASSOC)) {
print $theRow['content'] . "(".$theRow['id'].")<br>";
$theID = $theRow['id'];
$subResult = mysql_query("SELECT * FROM questionTree WHERE refID='$theID'",$db);
printOut($subResult);
}
}
It hits the top three items in the database, but it can't figure out any of the sub-items, I get this error:
Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /var/www/html/treeEditor.php for lines 6 & 9.
So I know that there's something I don't understand about how mySQL queries work . . . but I don't really know how to fix the problem. Any suggestions?