Ciao a tutti, ho un problema con un ciclo if.
devo fare eseguire una query per la ricerca di campi in un db.
ho tre elementi (id, nome, cognome) la ricerca deve essere possibile con tutte le combinazioni possibili (o solo id, o id e nome o nome e cognome, ecc)
come devo impostare i cilci if? io ho fatto così ma non mi funziona.
aiutatemi pliss
PS correggetemi anche se trovate qlc errore di sintassi...sono alle prime armi!
grazie
$id = $_POST['codba'];
$nome = $_POST['nomeart'];
$cognome = $_POST['codcd'];
if ($id != " "){
$query_id ="select * from tabella where ida = '" . $id ."'";
$result = mysql_query($query_id) or die('Query failed: ' . mysql_error());}
elseif ($nome != " "){
$query_nome ="select * from tabella where nomea = '" . $nome ."'";
$result = mysql_query($query_nome) or die('Query failed: ' . mysql_error());}
elseif ($cognome != " "){
$query_cognome ="select * from tabella where cognomea = '" . $cognome ."'";
$result = mysql_query($query_cognome) or die('Query failed: ' . mysql_error());}
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
?>
<table>
<tr>
<td><?php echo $row["ida"]; ?></td>
<td><?php echo $row["nomea"]; ?></td>
<td><?php echo $row["cognomea"]; ?></td>
</tr>
<?php
} ?>
</table>