OK, I'm having a problem nesting 2 while loops together. Here's the code. It gives me the error "WARNING; Supplid argument is not valid MySQL-Link resource in /www/test/test.php in line 11" and the same thing for line 13 for one entry in the DB.
<?php
$dbh 0 mysql_connect("localhost", "root", "") ;
mysql_select_db("test") ;
function folder_tree($row_id) {
$stmt_2 = "SELECT * from int_test WHERE sub != 0" ;
$sth_2 = mysql_query($stmt_2, $dbh) ;
while ($sec_row = mysql_fetch_array($sth_2)){
echo "Second while" ;
if ($row_id == $sec_row["sub"]) {
echo "<tr> \n" ;
printf("<td> %s </td> \n", $sec_row["sub"]);
echo "</tr> \n" ;
}
}
}
$stmt = "SELECT * FROM int_test WHERE sub = 0" ;
$sth = mysql_query($stmt, $dbh) ;
echo "<table> \n" ;
while ($row = mysql_fetch_array($sth)) {
echo "<tr> \n" ;
printf("<td> %s </td> \n", $row["name"]) ;
folder_tree($row["row"]) ;
echo "</tr> \n" ;
}
echo "</table> \n" ;
?>