Click to See Complete Forum and Search --> : Challenge _ List Values According To A Dynamic Populated Combo Box


rogernem
November 8th, 2004, 06:38 AM
Hi there. I have a table called menu where there are some menu itens there. I also have a table called "produtos" where I have some products there and their corresponding menu.

MENU
==== ==
$menuitem
Wallpapers
Icons


PRODUTOS
========
$nomeproduto...........$menuitem
Tim...........................Wallpapers
Motorola....................Wallpapers
House........................Icons

Something like that

Well, I have a combo box (dropdown) that is populated according to the itens in the menu table.
What I'd like to do is to list the itens in the table corresponding to that menu item
The way the code is, it just populates the combo but it doesnt show the itens when i change the value of the combo

The code follows bellow:


<?php
include ("../toing_conexao.php");
?>


<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<p align="center"><strong>ADMIN TOING - PRODUTOS : <a href="index.php">Voltar</a> <br>
</strong></p>
<table width="700" border="0" align="center" cellpadding="0" cellspacing="0">
<form action="action_addproditens.php" method="post">
<tr>
<td>* Categoria: </td>
<td>

<?php
$query="SELECT * FROM menu order by menuitem ASC";
$result=mysql_query($query);
$num=mysql_num_rows($result);
?>

<select name="menuitem" style="width:200 " onChange="<? $acao ?>">

<?
$i=0;
while ($i < $num) {
?>

<option>

<?
$menuitem=mysql_result($result,$i,"menuitem");
echo $menuitem;
$i++;
if ($select != 1) {
$acao;
}
}
?>

</option>
</select>
</td>
</tr>

<tr>
<td width="205">* Nome do Produto: </td>
<td width="495"><input name="nomeproduto" type="text" ></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td colspan="2"><input type="reset" name="Reset" value="Limpar">
<input type="submit" name="Submit2" value="Adicionar"></td>
</tr>
</form>
</table>

<p><strong> Produtos existentes:</strong></p>

<?
if ( $acao ) {
$sql2="SELECT * FROM produtos WHERE menuitem = '$menuitem' ORDER BY nomeproduto ASC";
$result2=mysql_query($sql2,$conn);

while ($row = mysql_fetch_array($result2)) {
$id = $row["id_prod"];
$menuitem = $row["menuitem"];
$nomeproduto = $row["nomeproduto"];

echo ("<font face=verdana size=2>- $nomeproduto</font>");
echo "<br>";
}
}
?>

</body>
</html>

If I select "Wallpapers" in the combo I'd like to show in the page:

Produtos existentes:
Tim
Motorola

and if I select "Icons" i'd like to show

Produtos existentes:
House


WHAT SHOUD I DO??
Thank you !!