scusatemi tanto, solo adesso mi rendo conto che con la fretta ho postato nella sezione sbagliata, potreste per favore spostarla nella sezione php-mysql, grazie mille 
tokyo74
Post
-
selezionare un campo da un db con radio button -
ciao a tutti, piacere di essere quìciao a tutti mi chiamo Luca alias tokyo74 e spero di trovarmi bene con voi, un buon martedì a tutti

-
selezionare un campo da un db con radio button[h=2]salve a tutti,
spero mi possiate aiutare in un mio grattacapo che non sto riuscendo a venirne a capo, spiego la situazione:
Ho un form che contiene un tasto di ricerca che filtra i dati dal db tramite la scelta della citta del distributore e tutto quì funziona, alla stessa query stavolta tramite dei radio button deve selezionare un altro attributo del db che sceglie il tipo di carburante, ma non riesco a capire come prendere il dato dal radio button e metterlo nella query per fare un altro ulteriore filtraggio.Codice html per il form contenente il tasto di ricerca e i radio button:
... <body> <form class="form-horizontal" role="form" method="get"> <div class="form-group"> <label class="col-sm-2 control-label" for="name">Città Distributore</label> <div class="input-group col-sm-8"> <input id="name" name="name" type="text" class="form-control" placeholder="Inserisci la città" /> <span class="input-group-btn"> <button type="button" class="btn btn-default btnSearch"> <span class="glyphicon glyphicon-search"> Search</span> </button> </span> </div> </div> <form class="form-horizontal" role="form" method="get"> <fieldset> <legend>Scegli il carburante</legend> Benzina <input type="radio" name="nomeCarburante" value="benzina"/> Diesel <input type="radio" name="nomeCarburante" value="diesel"/> GPL <input type="radio" name="nomeCarburante" value="gpl"/> Metano <input type="radio" name="nomeCarburante" value="metano"/> Benzina SP <input type="radio" name="nomeCarburante" value="benzina SP"/> Diesel SP <input type="radio" name="nomeCarburante" value="diesel SP"/> </fieldset> </form> </form> </body>codice php per prelevare i dati dal form del tasto di ricerca ancora manca il codice per prelevare i dati dai radio button:
require_once 'Connection.simple.php'; $conn = dbConnect(); $OK = true; // We use this to verify the status of the update. // If 'buscar' is in the array $_POST proceed to make the query. if (isset($_GET['name'])) { // Create the query $data = "%".$_GET['name']."%"; $sql = 'SELECT d.nomeDistributore,d.indirizzo,d.citta,d.provincia,d.tipologia, c.nomeCarburante,f.prezzo,f.dataArrivo, s.disponibile FROM distributore d, carburante c, fornitura f, servire s WHERE d.idDistributore=s.idDistributore and d.idDistributore=f.idDistributore and c.idCarburante=f.idCarburante and d.citta like? order by f.prezzo'; // we have to tell the PDO that we are going to send values to the query $stmt = $conn->prepare($sql); // Now we execute the query passing an array toe execute(); $results = $stmt->execute(array($data)); // Extract the values from $result $rows = $stmt->fetchAll(); $error = $stmt->errorInfo(); echo $error[2]; } // se non ci sono records. if(empty($rows)) { echo "<tr>"; echo "<td colspan='8'>Non ci sono records</td>"; echo "</tr>"; } else { foreach ($rows as $row) { echo "<tr>"; echo "<td>".$row['nomeDistributore']."</td>"; echo "<td>".$row['indirizzo']."</td>"; echo "<td>".$row['citta']."</td>"; echo "<td>".$row['provincia']."</td>"; echo "<td>".$row['tipologia']."</td>"; echo "<td>".$row['nomeCarburante']."</td>"; echo "<td>".$row['prezzo']."</td>"; echo "<td>".$row['dataArrivo']."</td>"; echo "<td>".$row['disponibile']."</td>"; echo "</tr>"; } }alla query che restituisce i dati opportuni con la selezione della citta distributore tramite il like devo aggiungere una selezione del tipo c.nomeCarburante='scelta dei radio button'
come posso fare? ho provato in diversi modi ma non funziona, mi date una mano per piacere, grazie[/h] -
Dati prelevati dal database che si ripetonoGrazie per la risposta, ho già risolto.

L'errore stava proprio nelle query nel modo in cui interrogavo le tabelle.
I dati si trovavano tutti in una tabella quelli che mi interessavano ed io interrogavo tutti e tre le tabelle ecco perchè combinavo un casino
Grazie, ciao. -
Dati prelevati dal database che si ripetonoSalve a tutti,
ho un problema, ho creato un piccolo programma che gestisce le cimmissioni di utenti ecc. Tutto apposto se non che quando prelevo i dati dal database con php nella tabella compaiono alcuni campi ripetuti ed altri che non ci sono, cioè quando vedo le commissioni di un utente alcune commissioni sono ripetute e altri che ci dovrebbero essere non compaiono, non capisco dove sbaglio, mi potete aiutare, posto il codice:<?php session_start(); include "util.php"; include "connetti.php"; if($_SESSION['admin'] == true){ $gginiz=$_REQUEST['gginiz']; $mminiz=$_REQUEST['mminiz']; $aainiz=$_REQUEST['aainiz']; $ggfine=$_REQUEST['ggfine']; $mmfine=$_REQUEST['mmfine']; $aafine=$_REQUEST['aafine']; $controllo="0000-00-00"; $datainizio=$aainiz."-".$mminiz."-".$gginiz; $datafine=$aafine."-".$mmfine."-".$ggfine; if(htmlspecialchars($_REQUEST['username']) != null){ ?> <form action="visualizzacomm.php"> <input type="hidden" name="username" value="<?php echo htmlspecialchars($_REQUEST['username']); ?>"> data inizio(gg/mm/aaaa): <input type="textbox" name="gginiz" value="00" size="2"> / <input type="textbox" name="mminiz" value="00" size="2"> / <input type="textbox" name="aainiz" value="0000" size="4"><br> data fine(gg/mm/aaaa): <input type="textbox" name="ggfine" value="00" size="2"> / <input type="textbox" name="mmfine" value="00" size="2"> / <input type="textbox" name="aafine" value="0000" size="4"><br> <input type="submit" value="Ok"> </form> <?php if($datainizio != $controllo && $datafine != $controllo){ $query = "select * from impiegato, commessa, impiegato_has_commessa where (impiegato.username = '".htmlspecialchars($_REQUEST['username'])."') AND (impiegato.username = impiegato_has_commessa.impiegato_username) AND (impiegato_has_commessa.commessa_idcommessa = commessa.idcommessa) AND (DATEDIFF(commessa.data, DATE('".$datainizio."')) > 0) AND (DATEDIFF(commessa.data, DATE('".$datafine."')) < 0)"; /* $query = "select * from commessa where (commessa.username = '".htmlspecialchars($_REQUEST['username']) AND (DATEDIFF(commessa.data, DATE('".$datainizio."')) > 0) AND (DATEDIFF(commessa.data, DATE('".$datafine."')) < 0)"'; */ } else{ $query = "select * from impiegato, commessa, impiegato_has_commessa where (impiegato.username = '".htmlspecialchars($_REQUEST['username'])."') AND (impiegato.username = impiegato_has_commessa.impiegato_username) AND (impiegato_has_commessa.commessa_idcommessa = commessa.idcommessa)"; /* $query = "select * from commessa, impiegato_has_commessa where (commessa.username = '".htmlspecialchars($_REQUEST['username'])."') AND (commessa.username = impiegato_has_commessa.impiegato_username) AND (impiegato_has_commessa.commessa_idcommessa = commessa.idcommessa)"; */ /* $query = "select * from commessa where (commessa.username = '".htmlspecialchars($_REQUEST['username'])"'; */ } $rows = mysql_query($query); $count=0; echo "username: ".htmlspecialchars($_REQUEST['username']); echo "<center><table border=1><tr><td>Commessa</td><td>Data Commessa</td><td>Ore Commessa</td><td>Minuti</td></tr>"; while($count < mysql_num_rows($rows)){ $row = mysql_fetch_assoc($rows); echo "<tr><td>".$row['nomecommessa']; echo "</td>"; echo "<td> ".get_correct_date($row['data']); echo "</td>"; echo "<td>".$row['commessa1']; echo "</td>"; echo "<td>".$row['minuti']; echo "</td>"; echo "</tr>"; $count= $count + 1; } echo "</table></center>"; } else{ $Data=$anno.'-'.$mese.'-'.$giorno; $query = "select * from impiegato"; $rows = mysql_query($query); if(mysql_num_rows($rows) == 0) echo "la tabella è vuota"; else{ echo "<table>"; while($row = mysql_fetch_assoc($rows)){ echo "<tr>"; echo "<td>"; echo "<span class='username'><a href='visualizzacomm.php?username=".$row["username"]."'>".$row["username"]."</a></span>"; echo "</td>"; echo "<td>"; echo "<span class='nome'>".$row["nome"]."</span>"; echo "</td>"; echo "<td>"; echo "<span class='cognome'>".$row["cognome"]."</span>"; echo "</td>"; echo "</tr>"; } echo "</table>"; } } mysql_close($Connessione); } else { echo "non hai accesso alla pagina"; } ?>