Ok Guys I am seriously stuck with this. Despite reading a dozen solutions I cannot get it straight..
Here is my MySql table..uid stands for user id and parentid stands for the parent where the user belongs.
id parentid uid
1 0 1
2 1 2
3 1 3
4 2 4
5 2 5
6 3 6
7 3 7
Now this is what I did.
$con = mysql_connect("localhost","rtest","123456");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
else
{
mysql_select_db("rtest", $con);
$sql="SELECT * FROM parentchild WHERE parentid=1";
$results=mysql_query($sql);
while($row = mysql_fetch_array($results))
{
$levelone[] = $row;
}
}
mysql_close($con);
foreach ($levelone as &$value) {
echo $value[uid]."<br>";
}
Here I have childs of the 1st element. I am unable to figure out how to take the second array and get the further values and store them in more arrays. I also need to access individual arrays later and I cannot call the entire table in one array for security reasons. My logic is really weak here.
Please help and advice. Thanx a ton in advance..