Respected Sir, I am getting nested categories in a dropdown by the following function.
<?php
/*
Function lists all items in table tb_category
- id
- pid
- name
*/
require_once("../config.php");
mysql_connect($mysql_hostname,$mysql_user,$mysql_password);
mysql_select_db($mysql_database);
function RecursiveCat($pid)
{
static $level=0;
static $strid="";
static $strname="";
$sql=mysql_query("select * from tb_category where pid = '$pid' order by name ");
while($row=mysql_fetch_assoc($sql))
{
$id=$row['id'];
$level--;
$pad="";
for($p=1;$p<($level*-1);$p++) $pad.=" - ";
$strname.='<option value="'.$row['id'].'">'.$pad.$row['name'].'</option>';
$rid=RecursiveCat($id);
$strid[]=$row['id'];
$level++;
}
return $strname;
}
echo '<select name="dropdown_categories">';
echo RecursiveCat(0);
echo '</select>';
?>
And the screenshot is http://guest.webege.com/screenshots/dropdown_categories.jpg
Sir, my request is how to make the root category starts from one particular id ?( from employees in that screen shot example image) I hope you will consider my request and guide me. yours faithfully murulimadhav