0) $strRicerca = ' a ' . $strRicerca; if ($_REQUEST['type'] != '') { if ($strBaseQuery != "") $strBaseQuery .= " AND"; $strBaseQuery .= " type_" . $_REQUEST['type'] . " = 1"; } switch ($_REQUEST['type']) { case 'consigliato': $strRicerca = 'Ristoranti consigliati' . $strRicerca; break; case 'pesce': $strRicerca = 'Ristoranti di pesce' . $strRicerca; break; case 'carne': $strRicerca = 'Ristoranti di carne' . $strRicerca; break; case 'nouvelle': $strRicerca = 'Cucina creativa' . $strRicerca; break; case 'trattoria': $strRicerca = 'Trattorie' . $strRicerca; break; case 'osteria': $strRicerca = 'Osterie' . $strRicerca; break; case 'pizzeria': $strRicerca = 'Pizzerie' . $strRicerca; break; case 'agriturismo': $strRicerca = 'Agriturismi' . $strRicerca; break; case 'enoteca': $strRicerca = 'Enoteche' . $strRicerca; break; case 'etnico': $strRicerca = 'Ristoranti etnici' . $strRicerca; break; default: $strRicerca = 'Ristoranti' . $strRicerca; } if ($_REQUEST['nome'] != '') { if ($strBaseQuery != "") $strBaseQuery .= " AND"; $strBaseQuery .= " nome LIKE '%" . mysql_real_escape_string($_REQUEST['nome']) . "%'"; $strRicerca .= ' con "' . htmlentities(stripslashes($_REQUEST['nome'])) . '" nel nome'; } // Manage paging $blnNewSearch = true; $intCount = 0; // Numero totale di ristoranti rispondenti alla ricerca $intNorm = 0; // Numero ristoranti sottili rispondenti alla ricerca $intLarge = 0; // Numero ristoranti grossi, ma senza scheda (priorita' 1), rispondenti alla ricerca $intBigSpace = 3; // I ristoranti grossi o con scheda occupano 3 posti $intPosition = 0; $intPaging = 15; // Massimo numero di ristoranti per pagina if (isset($_REQUEST['count'])) { $intCount = (int) $_REQUEST['count']; $intNorm = (int) $_REQUEST['norm']; $blnNewSearch = false; } if (isset($_REQUEST['position'])) { $intPosition = (int) $_REQUEST['position']; if ($intPosition < 0) $intPosition = 0; $blnNewSearch = false; } if ($blnNewSearch) { // Determine the number of total documents $strQuery = "SELECT count(*) AS total FROM ristoranti"; if (strlen($strBaseQuery) > 0) $strQuery .= " WHERE" . $strBaseQuery; $rstTotal = mysql_query($strQuery) or die('Query ' . $strQuery . ' fallita: ' . mysql_error()); $recTotal = mysql_fetch_array($rstTotal, MYSQL_ASSOC); mysql_free_result($rstTotal); $intCount = (int) $recTotal['total']; // Determine the number of large documents $strQuery = "SELECT count(*) AS total FROM ristoranti WHERE priority = 1"; if (strlen($strBaseQuery) > 0) $strQuery .= " AND" . $strBaseQuery; $rstTotal = mysql_query($strQuery) or die('Query ' . $strQuery . ' fallita: ' . mysql_error()); $recTotal = mysql_fetch_array($rstTotal, MYSQL_ASSOC); mysql_free_result($rstTotal); $intLarge = (int) $recTotal['total']; // Determine the number of normal documents $strQuery = "SELECT count(*) AS total FROM ristoranti WHERE priority = 0"; if (strlen($strBaseQuery) > 0) $strQuery .= " AND" . $strBaseQuery; $rstTotal = mysql_query($strQuery) or die('Query ' . $strQuery . ' fallita: ' . mysql_error()); $recTotal = mysql_fetch_array($rstTotal, MYSQL_ASSOC); mysql_free_result($rstTotal); $intNorm = (int) $recTotal['total']; } $intMaxSponsor = 2; // Massimo numero di sponsor per pagina $strQuery = "SELECT DISTINCT sponsor.* FROM sponsor "; if (strlen($strLocalitaXAree) > 0) $strQuery .= ", sponsorxaree, localitaxaree WHERE" . $strLocalitaXAree . " AND localitaxaree.area = sponsorxaree.area AND sponsorxaree.sponsor = sponsor.id"; else $strQuery .= "WHERE NOT EXISTS (SELECT area FROM sponsorxaree WHERE sponsor = sponsor.id)"; $strQuery .= " ORDER BY sponsor.ordine LIMIT 0, " . $intMaxSponsor; $rstSponsor = mysql_query($strQuery) or die('Query ' . $strQuery . ' fallita: ' . mysql_error()); $i = 0; while ($recSponsor = mysql_fetch_array($rstSponsor, MYSQL_ASSOC)) { if ($i == 0) { ?>
 
0) echo 'vspace="3"'; echo '>
'; if (strlen($recSponsor['link']) > 0) echo ''; echo ' 0) echo ' alt="' . htmlentities($recSponsor['alt']) . '"'; if (strlen($recSponsor['link']) > 0) echo '>
'; } // Free the ResultSet mysql_free_result($rstSponsor); if ($i > 0) { ?>
0) $strQuery .= " WHERE" . $strBaseQuery; $strQuery .= " ORDER BY priority DESC, nome LIMIT " . $intPosition . ", " . $intPaging; $rst = mysql_query($strQuery) or die('Query ' . $strQuery . ' fallita: ' . mysql_error()); echo '' . $strRicerca . '
'; $i = 0; $quanti = 0; $norm = 0; while ($rec = mysql_fetch_array($rst, MYSQL_ASSOC)) { $quanti++; if ($rec['priority'] > 0) { // Ristorante grosso o con scheda if ($i == 0) { // E' il primo ?>'; echo ''; echo ''; echo ''; echo ''; $i += $intBigSpace; } else { // Ristorante normale if ($norm == 0) { // E' il primo if ($i > 0) // Prima c'erano dei ristoranti grossi o con scheda echo '
'; if (strlen($rec['thumb1'])) echo ''; echo ''; if ($rec['type_consigliato'] == 1) echo 'Vai alla scheda ristorante consigliato da itinerario di sapori'; echo '' . xmlentities($rec['nome']) . '
'; echo '' . xmlentities($rec['descr']) . '
'; echo 'Piatto tipico: ' . xmlentities($rec['piatto']) . '
'; echo 'Tipo di cucina: ' . xmlentities($rec['cucina']) . '
'; echo 'Tel. ' . xmlentities($rec['telefono']) . '
'; echo xmlentities($rec['indirizzo']) . ' - ' . xmlentities($rec['localita']) . ' ' . xmlentities($rec['comune']) . '
'; echo 'Chiuso: ' . xmlentities($rec['chiusura']) . '
'; ?>
' . xmlentities($rec['nome']) . ' ' . xmlentities($rec['descr']) . '
' . xmlentities($rec['localita']) . ' ' . xmlentities($rec['comune']) . ' - ' . xmlentities($rec['indirizzo']) . ' Tel. ' . xmlentities($rec['telefono']); if (strlen($rec['chiusura']) > 0) echo ' Chiuso: ' . xmlentities($rec['chiusura']); echo ' '; $norm++; } if ($i+1 > $intPaging) break; } if (($norm == 0) && ($i > 0)) // Chiudo i ristoranti grossi o con scheda echo '
'; if ($norm > 0) { // Chiudo i ristoranti normali ?>
Nessun ristorante trovato con queste caratteristiche
$intPaging) { // Pagination $intBig = $intCount - $intNorm; echo '
'; if ($intPosition > 0) { $newPosition = $intPosition - $intPaging; if ($newPosition < $intBig) $newPosition = $intPosition - ($intPosition - $intBig) - (($intPaging - ($intPosition - $intBig)) / $intBigSpace); if ($intPosition <= $intBig) $newPosition = $intPosition - ($intPaging / $intBigSpace); echo '< Precedente  '; } $j = 1; $k = 0; while ($k < $intCount) { if ($k == $intPosition) echo $j . '  '; else echo '' . $j .'  '; if ($k >= $intBig) $k += $intPaging; elseif ($k + ($intPaging / $intBigSpace) <= $intBig) $k += ($intPaging / $intBigSpace); else $k += ($intBig - $k) + ($intPaging - (($intBig - $k) * $intBigSpace)); $j++; } if ($intPosition + $intPaging < $intCount) { $newPosition = $intPosition + $quanti; echo 'Successiva >'; } echo '
'; } ?>