Forum Moderators: coopster
Just curious to know is it possible to create directories on the fly?
What I have done is created a script when you can add categories and subcategories, but what I would like to do is create a directory physcially within that category. For instance using the mkdir command using linux. In a way traversing through and creating a directory.
An example would be:
If I created a category called business and econony then it would display this in the address bar.
[domain.com...]
Then perhaps under Business and Economy, a category called Accounting, then it would display the following:
[domain.com...]
Hopefully I'm making some sense here.
Heres the code:
function maketree($rootcatid,$level)
{
$sql="select catid,cat_name
from quiz_category
where parentid=$rootcatid
order by cat_name";
$result=mysql_query($sql);
while (list($DBcatid,$DBcatname)=mysql_fetch_row($result))
{
$width=($level+1)*24;
$display="<img src=http://www.domain.com/spacer.gif border=0 width=$width height=12>";
if ($DBcatid==1)
{
$display.="<input type=\"radio\" name=\"quest_type\" value=$DBcatid checked>";
}
else
{
$display.="<input type=\"radio\" name=\"quest_type\" value=$DBcatid>";
}
$display.="$DBcatname<br>\n";
echo $display;
maketree($DBcatid,$level+1);
}
}
if ($submit=='Add New Category')
{
if ($new_cat!='')
{
mysql_query("insert into quiz_category
(parentid,cat_name) values ($quest_type,'$new_cat')");
# need to create directory here
echo "<br><br><center><b>New category entered</b></center>";
}
else
echo "<br><br><center><b>New category name must be entered</b></center>";
}
Many Thanks
W :o)
mkdir()[be.php.net].
This might be what you're looking for. In the user-contributed notes you can find functions for creating multiple directories.