Now, I got this to work, but I'm sure I'm being redundant in it, but I don't know where. Could someone take a look at this code and point out any obvious redundancies?
CODE
<?
require_once './config.php';
require_once './classes/class_mysql_nest.php';
$mysql = new mysql;
function dash($num)
{
$i = 0;
while ($i < $num)
{
echo "-";
$i++;
}
}
echo "Starting General Nested Test<br>\n";
$connection = $mysql->db_connect($host,$user,$pass);
$mysql->db_select($db,$connection);
$query = 'SELECT * FROM `samp_nested` WHERE `parent` = 0';
$parents = $mysql->db_query($query);
while ($parent = mysql_fetch_assoc($parents))
{
$nestnum = 0;
printf ("<b>%s</b>",$parent["name"]);
print "<br>";
$query = 'SELECT * FROM `samp_nested` WHERE `parent` = '.$parent["tid"];
$children = $mysql->db_query($query);
if (mysql_num_rows($children) != 0)
{
$nestnum++;
while ($child = mysql_fetch_assoc($children))
{
$curchi = $child;
dash($nestnum);
printf ("<b>%s</b>",$child["name"]);
print "<br>";
while (mysql_num_rows($children) != 0)
{
$nestnum++;
$query = 'SELECT * FROM `samp_nested` WHERE `parent` = '.$curchi["tid"];
$children = $mysql->db_query($query);
while ($child = mysql_fetch_assoc($children))
{
$curchi = $child;
dash($nestnum);
printf ("<b>%s</b>",$child["name"]);
print "<br>";
}
}
}
}
print "<br>";
}
$mysql->db_disconnect($connection);
?>
require_once './config.php';
require_once './classes/class_mysql_nest.php';
$mysql = new mysql;
function dash($num)
{
$i = 0;
while ($i < $num)
{
echo "-";
$i++;
}
}
echo "Starting General Nested Test<br>\n";
$connection = $mysql->db_connect($host,$user,$pass);
$mysql->db_select($db,$connection);
$query = 'SELECT * FROM `samp_nested` WHERE `parent` = 0';
$parents = $mysql->db_query($query);
while ($parent = mysql_fetch_assoc($parents))
{
$nestnum = 0;
printf ("<b>%s</b>",$parent["name"]);
print "<br>";
$query = 'SELECT * FROM `samp_nested` WHERE `parent` = '.$parent["tid"];
$children = $mysql->db_query($query);
if (mysql_num_rows($children) != 0)
{
$nestnum++;
while ($child = mysql_fetch_assoc($children))
{
$curchi = $child;
dash($nestnum);
printf ("<b>%s</b>",$child["name"]);
print "<br>";
while (mysql_num_rows($children) != 0)
{
$nestnum++;
$query = 'SELECT * FROM `samp_nested` WHERE `parent` = '.$curchi["tid"];
$children = $mysql->db_query($query);
while ($child = mysql_fetch_assoc($children))
{
$curchi = $child;
dash($nestnum);
printf ("<b>%s</b>",$child["name"]);
print "<br>";
}
}
}
}
print "<br>";
}
$mysql->db_disconnect($connection);
?>
I'm attaching the output from the script
Click to view attachment