Grazie mille Fractals, ho fatto cosi, ma alla pressione del tasto Test non accade nulla, ho comesso sicuramente qualche errore. Il codice è questo:
Codice PHP:
<script language="javascript" type="text/javascript" src="C:/Bitnami/wampstack-5.4.30-0/scripts/JQuery/jquery-1.11.1.min.js">
function call_ajax(){
$.ajax({
type: "POST",
url: "../risultati.php",
dataType: "html",
data: "dato1=" + $("#dato1").val() + "&dato2=" + $("dato2").val(),
async: true,
cache: false,
timeout:30000,
success: function(html){
alert(html);
}
});
}
</script>
form name="tabella"target ="risultati" action="" method="POST">
<table width="80%" border="0">
<colgroup bgcolor="#FFFFFF" width="45%" align="right"></colgroup>
<colgroup bgcolor="#FFFFFF" width="15%" align="right"></colgroup>
<colgroup bgcolor="#FFFFFF" width="45%" align="right"></colgroup>
<colgroup bgcolor="#FFFFFF" width="15%" align="right"></colgroup>
<colgroup bgcolor="#FFFFFF" width="15%" align="right"></colgroup>
<thead>
<tr>
<td>Matricola</b></td>
<td><input type="text" name="matricola"></td>
<td>Stato</b></td>
<td><input type="text" name="stato"></td>
</tr>
<tr>
<td>S/N</b></font></td>
<td><input type="text" name="sn"></td>
</tr>
</thead>
</table>
<input type="button" name="search" onclick="call_ajax()" value="test">
<?php
if (isset($_POST['search'])){
//Recupero i valori
$campo1 = $_POST['matricola'];
$campo2 = $_POST['stato'];
$campoN = $_POST['sn'];
//concateno le query per estrarre la query completa
$sql = 'SELECT * FROM eltfinal.strumenti WHERE 1=1';
$sql .= RecuperaFiltro($campo1,'matricola');
$sql .= RecuperaFiltro($campo2,'stato');
$sql .= RecuperaFiltro($campoN,'sn');
$sql .= ";";
$query= mysql_query ($sql,$connessione);
//echo '<form target="risultati" action="">';
echo $sql;
//inserisco la query in un array
$array = mysql_fetch_array($query);
echo $array['matricola'];
if (!$query)
{
print "NO";
}
else
{
print "SI";
}
//echo '</form>';
}
else
echo 'non hai premuto il tasto';
?>
</form>
</body>
</html>