Last active
December 22, 2015 20:39
-
-
Save nootanghimire/6527881 to your computer and use it in GitHub Desktop.
Get upto second child!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$q = "SELECT * FROM table WEHRE parent=0" ; | |
$res = mysql_query($q); | |
while ($row = mysql_fetch_array($res)){ | |
$q1 = "SELECT * FROM table WHERE parent = ". $row['id']; | |
$res1 = mysql_query($q1); | |
while($row1 = mysql_fetch_array($res1){ | |
$q2 = "SELECT * FROM table WHERE parent = ". $row1['id']; | |
$res2 = mysql_query($q2); | |
while($row2 = mysql_fetch_array($res2)){ | |
//echo Parent: $row | |
// First Child: $row1 | |
// Second Child: $row2 | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment