Codice PHP:
if(isset($_POST['submit_x'])) {
$data = $_POST['giorno'] . '/' . $_POST['mese'] . '/' . $_POST['anno'];
if($data == '//') { $data = NULL; }
$ragione = $_POST['ragione'];
$regione = $_SESSION['regione'];
if(($ragione == '') && ($data == '')) {
$query = "SELECT utenti.id AS id, utenti.code AS code, utenti.ragione AS ragione, utenti.nome, utenti.cognome, utenti.localita, utenti.provincia, utenti.regione, utenti.telefono FROM utenti,preventivi WHERE utenti.code=preventivi.user";
} elseif(($ragione != '') && ($data == '')) {
$query = "SELECT utenti.id AS id, utenti.code AS code, utenti.ragione AS ragione, utenti.nome, utenti.cognome, utenti.localita, utenti.provincia, utenti.regione, utenti.telefono FROM utenti,preventivi WHERE ragione LIKE '%$ragione%' AND utenti.code=preventivi.user";
} elseif(($ragione == '') && ($data != '')) {
$query = "SELECT utenti.id AS id, utenti.code AS code, utenti.ragione AS ragione, utenti.nome, utenti.cognome, utenti.localita, utenti.provincia, utenti.regione, utenti.telefono FROM utenti,preventivi WHERE day='$data' AND utenti.code=preventivi.user";
} elseif(($ragione != '') && ($data != '')) {
$query = "SELECT utenti.id AS id, utenti.code AS code, utenti.ragione AS ragione, utenti.nome, utenti.cognome, utenti.localita, utenti.provincia, utenti.regione, utenti.telefono FROM utenti,preventivi WHERE day='$data' AND ragione LIKE '%$ragione%' AND utenti.code=preventivi.user";
}
$query .= ' ORDER BY utenti.code';
$result = mysql_query($query, $db) or die(mysql_error());
echo "<table width=\"100%\">";
draw_headers();
while($sql_data = mysql_fetch_object($result)) {
/* Stampa formattata dei record.. */
draw_table($sql_data->id, $sql_data->code, $sql_data->ragione, $sql_data->nome, $sql_data->cognome, $sql_data->localita, $sql_data->provincia, $sql_data->regione, $sql_data->telefono);
$i++;
}
echo "</table>";
}
?>
Cosa posso fare per evitare che uno stesso cliente, appia più volte nella tabella?