Категории

Автор: | 28.05.2016
<?
include 'includes/sql.php';
$a=explode(',',$_POST['cat']);
print_r($a);
foreach($a as $k=>$v){
$d=mysql_query("insert into `cat` (`name`,`parent`) values ('$v','0') ");}
if ($d==true) echo 'true';

$d=mysql_query("select `id`,`name`,`parent` from `cat` where `parent`='0'");
var_dump($d);
while($l=mysql_fetch_assoc($d)){

?>
<ul>
<li><?= $l['name'];?></li>
<?$d2=mysql_query("select `id`,`name`,`parent` from `cat` where `parent`='{$l['id']}'");
while($l2=mysql_fetch_assoc($d2)){ ?>
<ul><li><?= $l2['name'];?>
<?$d3=mysql_query("select `id`,`name`,`parent` from `cat` where `parent`='{$l2['id']}'");
while($l3=mysql_fetch_assoc($d3)){ ?>
<ul><li><?= $l3['name'];?></li></ul>
<?}?>
</li></ul>
<?}?>
</ul>
<?}?>

<form method="post">
<input type='text' name='cat'>
<input type='submit' name='send'>
</form>

 

Раздел: PHP