Menu Child selection

Hello,

May i have some helps i m php beginers so in my menu i have 3 children category so i build this

function createSelectCat($current_category, $category_arr) {
//var_dump($category_arr);exit;

foreach($category_arr as $parent)
{
	if($current_category==$parent['category_id'])
		{
			$f = 'selected';
		}
	else
		{
			$f = '';
		}
	echo "<option value='".$parent['category_id']."' ".$f.">".$parent['category_name']."</option>";

	if($parent['child']) {
		foreach($parent['child'] as $row1) {
			if($current_category==$row1['category_id'])
				{
					$f = 'selected';
				}
			else
				{
					$f = '';
				}
			echo "<option value='".$row1['category_id']."' ".$f.">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".$row1['category_name']."</option>";
			
			
			
			
		}
	} 

How i may add my 2nd and 3rd child category on this code ?

Thank you for your help

what are you trying to make? You are talking about a menu but you try to draw options that belongs to a dropdown or <select> HTML element. A menu consist most times out of (nested) unsorted lists <ul>.

a dropdown cannot have child elements. Only option is the optgroups e.g.

<select id="cars">
  <optgroup label="Swedish Cars">
    <option value="volvo">Volvo</option>
    <option value="saab">Saab</option>
  </optgroup>
  <optgroup label="German Cars">
    <option value="mercedes">Mercedes</option>
    <option value="audi">Audi</option>
  </optgroup>
</select>
Sponsor our Newsletter | Privacy Policy | Terms of Service