mysql_connect("localhost", "long", "horn");
mysql_select_db("longhorn");
?>
Failisysteem
Kliki kataloogil, et lisada alamkataloog v6i fail. Kliki failil, et vaadata
ja muuta faili sisu.
function print_item($what, $curdepth, $maxdepth) {
echo "\n";
$res = mysql_query("select * from dirs where id=$what");
if (mysql_affected_rows()) {
$row = mysql_fetch_object($res);
echo "";
for ($i = 0; $i < $curdepth - 1; $i++)
echo " | ";
echo "";
if ($row->fail)
echo "(f) id, ");\">";
else
echo "(d) id, ", ", $row->sygavus + 1, ");\">";
echo $row->nimi;
echo " | ";
for ($i = $curdepth; $i < $maxdepth; $i++)
echo " | ";
echo "
\n";
}
}
function print_children($what, $curdepth, $maxdepth) {
print_item($what, $curdepth, $maxdepth);
$res = mysql_query("select id from dirs where vanem=$what");
if (mysql_affected_rows()) {
while ($row = mysql_fetch_row($res))
print_children($row[0], $curdepth + 1, $maxdepth);
}
}
function max_depth() {
$res = mysql_query("select distinct sygavus from dirs order by sygavus desc limit 1");
$row = mysql_fetch_row($res);
return $row[0] + 1;
}
print_children(1, 1, max_depth());
?>
mysql_close();
?>