Ciao,
ho la necessità di impoaginare i risultati della ricerca in tabella. Ora mi vengono visualizzati tramite echo. Se voglio metterli dentro una tanella html come devo fare?
Ecco solo il form html del file cerca.php
codice:
<div align="center">
<table border="0" width="873" id="table1" cellspacing="8">
<tr>
<td><span style="text-decoration: none; font-weight: 700">cerca</span> |
cerca</td>
</tr>
<tr>
<td><form method="POST" action="<?php echo $_SERVER['PHP_SELF'] ?>">
Stringa di ricerca:
<input type="text" size="100" name="keywords">
<input type="submit" name="search" value="cerca">
</p>
</form>
<hr></td>
</tr>
</table>
</div>
Ecco solo la parte php del file cerca.php
Codice PHP:
<?php
if ($_POST['search']){
if (!empty($_POST['keywords'])) {
$searchStr = $_POST['keywords'];
if (ereg("^[A-Za-z0-9_]+$", $searchStr)) {
mysql_connect($host,$user,$password)or die("non riesco a connettermi");
mysql_select_db($database)or die("non riesco selezionare il database");
print "Risultati per [b]<font color=#FF0000> \"$searchStr\"</font>[/b]
";
$keys = explode(" ", $searchStr);
for ($x = 0; $x < count($keys); $x++) {
$querystr = "SELECT * FROM tabella WHERE campo1 = \"$keys[$x]\" OR campo2 LIKE \"%$keys[$x]%\"";
$result = mysql_query($querystr);
if ($frow = mysql_fetch_array($result)) {
$found = true;
do {
echo "
[b]ID:[/b]" . $frow["campoid"] . "[b]Codice:[/b] ".$frow["campo2"]. "[b]Data inserimento:[/b]".$frow["campo3"]."
";
echo "[b]Descrizione:[/b]" . $frow["campo5"] ."
";
echo "[b]Query:[/b]
";
echo "" . $frow["campo4"] ."
";
echo "
<hr>
";
} while ($frow = mysql_fetch_array($result));
}
}
if (!$found) {
print("Nessun risultato
");
}
}
else {
print("La tua stringa di ricerca contiene caratteri illegali
");
}
}
else {
print("Devi entrare un stringa di ricerca
");
}
}
?>
Grazie