CHALLENGE _ LIST VALUES ACCORDING TO A DYNAMIC POPULATED COM
Posted: Mon Nov 08, 2004 6:04 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:
<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>
<select name="menuitem" style="width:200 " onChange="<? $acao ?>">
<option>
</option>
</select>
</td>
</tr>
<tr>
<td width="205">* Nome do Produto: </td>
<td width="495"><input name="nomeproduto" type="text" ></td>
</tr>
<tr>
<td> </td>
<td> </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>
</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 !!
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:
Code: Select all
<?php
include ("../toing_conexao.php");
?><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>
Code: Select all
<?php
$query="SELECT * FROM menu order by menuitem ASC";
$result=mysql_query($query);
$num=mysql_num_rows($result);
?>Code: Select all
<?
$i=0;
while ($i < $num) {
?>Code: Select all
<?
$menuitem=mysql_result($result,$i,"menuitem");
echo $menuitem;
$i++;
if ($select != 1) {
$acao;
}
}
?></select>
</td>
</tr>
<tr>
<td width="205">* Nome do Produto: </td>
<td width="495"><input name="nomeproduto" type="text" ></td>
</tr>
<tr>
<td> </td>
<td> </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>
Code: Select all
<?
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>";
}
}
?></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 !!