Io voglio creare un motore di ricerca con tre campi:
Parola Chiave, Regione(combo box) e Città(Combo box); la combo con le città si riempie in base al valore scelto nel campo regione.
Ho un problema, ognuno dei 3 campi deve essere a un form, ma come posso fare per mantenere l'ordine come citato sopra??
[PHP
<?php
$submit=$_POST['SUBMIT'];
echo("submit==$submit
");
$chiave=$_POST['chiave'];
echo("Parola_chiave=$chiave
");
$regione=$_POST['regione'];
$citta=$_POST['citta'];
echo("regione=$regione
");
echo("citta=$citta
");
$regione = $_POST['regione'];
if ($regione!=''){
$var=$regione;
}
$citta = $_POST['citta'];
if ($citta!=''){
$var1=$citta;
}
echo("VAR=$var
");
echo("VAR1=$var1
");
?>
<div align="center">
<form name="form4" method="post" action="search_1.php">
<input name="chiave" type="text" id="chiave7" >
</form>
</div>
<form name="form1" method="post" action="search_1.php">
<input name="regione23" type="hidden" id="regione23" value="<?php echo($_POST['chiave']);?>">
<table width="580" border="1" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="130" align="left" valign="middle">Categoria*</td>
<?php
mysql_select_db($database_conn, $conn);
$query_RS = "SELECT DISTINCT `tb_regioni`.`regione` FROM `tb_regioni` ORDER BY `tb_regioni`.`regione` ASC";
$RS = mysql_query($query_RS, $conn) or die(mysql_error());
$row_RS = mysql_fetch_assoc($RS);
$totalRows_RS = mysql_num_rows($RS);
?>
<td width="360" align="left" valign="middle"><div align="left">
<select name="regione" id="regione" onchange="document.form1.submit()">
<option></option>
<?php
if ($var==''){
$var=0;
}
do {
?>
<option value="<?php echo $row_RS['regione']?>"<?php if($var==$row_RS['regione']){ echo " selected";}?> ><?php echo $row_RS['regione']?></option>
<?php
} while ($row_RS = mysql_fetch_assoc($RS));
?>
</select>
</div>
</td>
</tr>
</table>
</form>
<form action="search_1.php" method="post" name="form2">
<?php
mysql_select_db($database_conn, $conn);
$query_RSsupporti_prod = "SELECT
`tb_regioni`.`citta`
FROM
`tb_regioni`
WHERE
(`tb_regioni`.`regione` = '$var')";
//echo($query_RSsupporti_prod);
$RSsupporti_prod = mysql_query($query_RSsupporti_prod, $conn) or die(mysql_error());
$row_RSsupporti_prod = mysql_fetch_assoc($RSsupporti_prod);
$totalRows_RSsupporti_prod = mysql_num_rows($RSsupporti_prod);
?>
<table width="580" border="1" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="121" align="left" valign="middle">Sottocategoria*</td>
<td width="338" align="left" valign="middle">
<select name="citta" id="citta" onchange="document.form2.submit()">
<option></option>
<?php
do {
?>
<option value="<?php echo $row_RSsupporti_prod['citta'];?>"<?php if($var1==$row_RSsupporti_prod['citta']){ echo " selected";}?> ><?php echo $row_RSsupporti_prod['citta']?></option>
<?php
} while ($row_RSsupporti_prod = mysql_fetch_assoc($RSsupporti_prod));
?>
</select>
</td>
</tr>
</table>
<input name="regione" type="hidden" id="regione" value="<? echo($var); ?>">
<input name="regione22" type="hidden" id="regione22" value="<?php echo($_POST['chiave']);?>">
</form>
<form name="form3" method="post" action="">
<div align="center">
<input name="regione2" type="hidden" id="regione4" value="<?php echo($_POST['chiave']);?>">
<input name="regione" type="hidden" id="regione" value="<?php echo("$var");?>">
<input name="citta" type="hidden" id="citta" value="<?php echo("$var1");?>">
<input name="SUBMIT" type="submit" id="SUBMIT" value="Cerca">
</div>
</form>
</p>
[/PHP]