HO QUESTO FORM
<form id="trova-smartphone" name="trovasmart" enctype="application/x-www-form-urlencoded" method="post" action="/smartphone/public/public/trovasmartphone"><table>
<tr><td id="aziendaProduttrice-label"><label for="aziendaProduttrice" class="optional">Marca</label></td>
<td class="element">
<select name="aziendaProduttrice" id="aziendaProduttrice">
<option value="Acer" label="Acer">Acer</option>
<option value="Apple" label="Apple">Apple</option>
<option value="Asus" label="Asus">Asus</option>
<option value="HTC" label="HTC">HTC</option>
</select></td><td class="errors"></td></tr>
<tr><td id="so-label"><label for="so" class="optional">Sistema Operativo</label></td>
<td class="element">
<select name="so" id="so">
<option value="" label=""></option>
<option value=" iOS 5.0" label=" iOS 5.0"> iOS 5.0</option>
<option value="Android Cupcake 1.5" label="Android Cupcake 1.5">Android Cupcake 1.5</option>
<option value="Android Donut 1.6" label="Android Donut 1.6">Android Donut 1.6</option>
<option value="Android Eclair 2.1" label="Android Eclair 2.1">Android Eclair 2.1</option>
<option value="Android Froyo 2.2" label="Android Froyo 2.2">Android Froyo 2.2</option>
<option value="Android Gingerbread 2.3" label="Android Gingerbread 2.3">Android Gingerbread 2.3</option>
<option value="Android Honeycomb 3.0" label="Android Honeycomb 3.0">Android Honeycomb 3.0</option>
<option value="Android Ice Cream Sandwich 4.0" label="Android Ice Cream Sandwich 4.0">Android Ice Cream Sandwich 4.0</option
<option value="Android Jelly Bean 4.1" label="Android Jelly Bean 4.1">Android Jelly Bean 4.1</option>
</select></td><td class="errors"></td></tr>
<tr><td id="gpu-label"><label for="gpu" class="optional">GPU</label></td>
<td class="element">
<select name="gpu" id="gpu">
<option value="" label=""></option>
<option value="Adreno 200" label="Adreno 200">Adreno 200</option>
<option value="Adreno 203" label="Adreno 203">Adreno 203</option>
<option value="Adreno 205" label="Adreno 205">Adreno 205</option>
<option value="Adreno 220" label="Adreno 220">Adreno 220</option>
<option value="Adreno 225 " label="Adreno 225 ">Adreno 225 </option>
<option value="Adreno 320" label="Adreno 320">Adreno 320</option>
<option value="Tegra 2" label="Tegra 2">Tegra 2</option>
<option value="Tegra 3" label="Tegra 3">Tegra 3</option>
</select></td><td class="errors"></td></tr>
<tr><td id="ram-label"><label for="ram" class="optional">RAM</label></td>
<td class="element">
<select name="ram" id="ram">
<option value="512" label="512">512</option>
<option value="576" label="576">576</option>
<option value="768" label="768">768</option>
<option value="1024" label="1024">1024</option>
<option value="2048" label="2048">2048</option>
</select></td><td class="errors"></td></tr>
<tr><td id="fotocamera-label"><label for="fotocamera" class="optional">Risoluzione Fotocamera</label></td>
<td class="element">
<select name="fotocamera" id="fotocamera>
<option value="3.15" label="3.15">3.15</option>
<option value="3.2" label="3.2">3.2</option>
<option value="5" label="5">5</option>
<option value="8" label="8">8</option>
<option value="13" label="13">13</option>
</select></td><td class="errors"></td></tr>
</table></form>
MIA FUNZIONE JQUERY CHE VOGLIO MODIFICARE ELIMINANDO GLI IF IN MODO CHE MI PRENDA IN AUTOMATICO I VARI SELECT CHE SELEZIONO UNO O + E MI AUMENTA DI CONSEGUENZA I VALORI DA PASSARE ALLA FUNZIONE AJAX
$("select").change(function(){
var valore = $(this).val();
var id = $(this).attr("id");
var urlpage;
if(id=="gpu"){
urlpage= "stampa.php?gpu="+valore
}else if(id=="aziendaProduttrice"){
urlpage= "stampa.php?aziendaProduttrice="+valore
}else if(id=="fotocamera"){
urlpage= "stampa.php?fotocamera="+valore
}
$.ajax({
url: urlpage,
type: "POST",
success: function(data) {
$("#result").html(data);
}
});
return false;
});
PAGINA STAMPA.PHP DOVE VORREI UNA QUERY DINAMICA CHE MI PRENDA I VALORI SELEZIONATI
<?php
include("../include/connect.php");
$conn=mysql_connect($HOST, $USER, $PASSWORD);
$db_ok=mysql_select_db($DB, $conn);
$a=$_GET['aziendaproduttrice'];
$b=$_GET['gpu'];
ecc...
$i=0;
$ris = mysql_query("SELECT * FROM cellulare WHERE aziendaProduttrice IN ('$a')", $conn);
while ($row = mysql_fetch_array($ris)) {
if($i++%4 == 0)
echo "</tr><tr>";
echo "<td class='image'> <img src=immagini/".$row["image"]."><br>";
echo '<a title="Smartphone" href="/smartphone/public/public/cell/idSmart/'.$row['idSmart'].'">';
$row['aziendaProduttrice'];' ';echo $row['nome'].'</td></a>';
}
echo "</tr></table>";
mysql_close($conn);
?>