Advertisement

08.29.2008 at 11:57AM PDT, ID: 23689785 | Points: 500
[x]
Attachment Details

PHP List/Menu

Asked by killers376 in PHP and Databases

Tags:

I m trying to write a php list menu .. in which the sub menu is selected from the previous menu but for me when i select main menu .. the sub menu is listed twice .. everything is fine in database I tried looping and i found its looping twice . I dunno where the error is ..

2) when I select multiple values and when i echo .. I m getting only the last select item

   Im posting the code...Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
if(isset($_POST['button']))
	{
	$a=$_POST['model'];
	echo $a;
	for($i=0;$i<sizeof($a);$i++)
		{ echo $a[$i]." "; }
	
	}
	
?>
 
 
<form name="form1" method="post" action="123.php">
    <input type="submit" name="button" id="button" value="Submit">
  </label>
  <p>&nbsp;</p>
  <p>
    <select name="make" id="make" onChange="javascript:form.submit()">
           
	
                   <option value="0" selected>Any</option>
              <?php 
$res_getmake = mysql_query("select name from resumecat");			  
	//echo mysql_num_rows($res_getmake) ;		  
if(mysql_num_rows($res_getmake)!=0)
{
	while($makerow=mysql_fetch_array($res_getmake))
	{
	echo $makerow['name'];
echo "<option value='".trim($makerow['name'])."' ";if ($_POST['make']==$makerow['name']) {echo "selected=\"selected\"";}echo ">".trim($makerow['name'])."</option>";
}// of while $hintrow
}	
?>
 
    </select>
    
    <select name="model" size="5" multiple="multiple">
              <option value="0" selected>Any</option>
              <?php 
		$res_getmake = mysql_query("select id from resumecat where name='".$_POST['make']."'");
		$id=mysql_fetch_array($res_getmake);
			  
			  $res_getmodel=mysql_query("SELECT * FROM resumesubcat where catid ='".$id['id']."' ORDER BY subcat ASC") or die(mysql_error()." at line 120");
if(mysql_num_rows($res_getmodel)!=0)
{
	while($modelrow=mysql_fetch_array($res_getmodel))
	{
echo "<option value='".trim($modelrow['subcat'])."' ";if ($_POST['model']==$modelrow['subcat']) {echo "selected=\"selected\"";}echo ">".trim($modelrow['subcat'])."</option>";
	}// of while $hintrow
}	
?>
    </select>
  </p>
  
  <p>&nbsp;</p>
</form>
[+][-]08.30.2008 at 10:28AM PDT, ID: 22352592

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628