ragazzi di questo motore di ricerca più impaginazione, ho un dubbio, secondo voi , mi impaginerà i risultati trovati dal motore di ricerca o tutti i dati nel db?
Code:
Codice PHP:
<?php
/* Dati da compilare */
$db_host = "localhost";
$db_user = "root";
$db_pass = "";
$db_name = "motore";
$db = mysql_connect($db_host, $db_user, $db_pass);
mysql_select_db($db_name, $db);
$regex = "^[A-Za-z0-9 ]+$";
/* Controlla che qualcosa sia stato inserito nella textbox */
if (trim($_POST['search']) == "" )
{
echo "Non hai inserito nessuna chiave di ricerca!";
}
/* Effettua la validazione delle chiavi inserite */
elseif (!eregi($regex, $_POST['search']) )
{
echo "Errore! Hai inserito caratteri non validi!
";
} else {
/* Ricerca codice */
$query = "SELECT * FROM impresa WHERE settore LIKE '%" . $_POST['search'] . "%' AND dove = '" . $_POST['dove'] . "' OR indirizzo = '" . $_POST['indirizzo'] . "' ORDER BY titolo ASC LIMIT 20";
$res = mysql_query($query, $db);
if (mysql_num_rows($res) == 0)
{
echo "Nessun risultato trovato!";
} else {
echo "<div class='margine'>";
while ($people = mysql_fetch_array($res))
{
echo $people['titolo']. "
<img src=img/loghi/". $people['logo']." align='right'>";
echo "<div>" . $people['descrizione']. "
";
echo "<div>" . $people['indirizzo']. "
";
echo "<div><a href=scheda.php?id=" . $people['id']. ">Scheda Tecnica</a>|<a href=galleria.php?id=" . $people['id']. ">Catalogo</a>
";
echo "<div class='immagine'></div>";
}
echo "</div>";
}
}
?></div>
<div align="center">
<?php
include('classe.php');
// get the pager input values
$page = $_GET['page'];
$limit = 20;
$result = mysql_query("select count(settore) from impresa");
$total = mysql_result($result, 0, 0);
// work out the pager values
$pager = Pager::getPagerData($total, $limit, $page);
$offset = $pager->offset;
$limit = $pager->limit;
$page = $pager->page;
// use pager values to fetch data
$query = "select * from impresa order by someField limit $offset, $limit";
$result = mysql_query($query);
// use $result here to output page content
// output paging system (could also do it before we output the page content)
if ($page == 1) // this is the first page - there is no previous page
echo "Indietro";
else // not the first page, link to the previous page
echo "<a href=\"cerca.php?page=" . ($page - 1) . "\">Indietro</a>";
for ($i = 1; $i <= $pager->numPages; $i++) {
echo " | ";
if ($i == $pager->page)
echo "Page $i";
else
echo "<a href=\"cerca.php?page=$i\">Page $i</a>";
}
if ($page == $pager->numPages) // this is the last page - there is no next page
echo "|Avanti";
else // not the last page, link to the next page
echo "<a href=\"cerca.php?page=" . ($page + 1) . "\">Avanti</a>";
?>
</div>
GRAZIE IN ANTICIPO PER LE RISPOSTE