Codice PHP:
<?
echo "<dl id=prodlist>";
//definisco le variabili per l'insert nel db
$categoria = ltrim(rtrim(strip_tags(stripslashes($_POST['categoria']))));
$cucinaq = ltrim(rtrim(strip_tags(stripslashes($_POST['cucinaq']))));
$pulizia = ltrim(rtrim(strip_tags(stripslashes($_POST['pulizia']))));
$cortesia = ltrim(rtrim(strip_tags(stripslashes($_POST['cortesia']))));
$provincia = ltrim(rtrim(strip_tags(stripslashes($_POST['provincia']))));
$telefono = ltrim(rtrim(strip_tags(stripslashes($_POST['telefono']))));
$nomelocale = ltrim(rtrim(strip_tags(stripslashes($_POST['nomelocale']))));
$indirizzo = ltrim(rtrim(strip_tags(stripslashes($_POST['indirizzo']))));
$comune = ltrim(rtrim(strip_tags(stripslashes($_POST['comune']))));
$chiusura = ltrim(rtrim(strip_tags(stripslashes($_POST['chiusura']))));
$prezzomedio = ltrim(rtrim(strip_tags(stripslashes($_POST['prezzomedio']))));
$vini = ltrim(rtrim(strip_tags(stripslashes($_POST['vini']))));
$posti = ltrim(rtrim(strip_tags(stripslashes($_POST['posti']))));
$tipocucina = ltrim(rtrim(strip_tags(stripslashes($_POST['tipocucina']))));
$prenotazione = ltrim(rtrim(strip_tags(stripslashes($_POST['prenotazione']))));
$dehor = ltrim(rtrim(strip_tags(stripslashes($_POST['dehor']))));
$fumo = ltrim(rtrim(strip_tags(stripslashes($_POST['fumo']))));
$parking = ltrim(rtrim(strip_tags(stripslashes($_POST['parking']))));
$cartecredito = ltrim(rtrim(strip_tags(stripslashes($_POST['cartecredito']))));
$linguaggio = ltrim(rtrim(strip_tags(stripslashes($_POST['linguaggio']))));
$animali = ltrim(rtrim(strip_tags(stripslashes($_POST['animali']))));
$condizionatore = ltrim(rtrim(strip_tags(stripslashes($_POST['condizionatore']))));
$handicapp = ltrim(rtrim(strip_tags(stripslashes($_POST['handicapp']))));
$descrizione = ltrim(rtrim(strip_tags(stripslashes($_POST['descrizione']))));
$where_clause = " ";
if ($categoria!=""){if (isset($_POST['categoria']))
$where_clause .= " categoria='$categoria' AND ";}
if ($cucinaq!=""){if (isset($_POST['cucinaq']))
$where_clause .= " cucinaq='$cucinaq' AND ";}
if ($pulizia!=""){if (isset($_POST['pulizia']))
$where_clause .= " pulizia='$pulizia' AND ";}
if ($cortesia!=""){if (isset($_POST['cortesia']))
$where_clause .= " cortesia='$cortesia' AND ";}
if ($chiusura!=""){if (isset($_POST['chiusura']))
$where_clause .= " chiusura='$chiusura' AND ";}
if ($prezzomedio!=""){if (isset($_POST['prezzomedio']))
$where_clause .= " prezzomedio='$prezzomedio' AND ";}
if ($vini!=""){if (isset($_POST['vini']))
$where_clause .= " vini='$vini' AND ";}
if ($posti!=""){if (isset($_POST['posti']))
$where_clause .= " posti='$posti' AND ";}
if ($tipocucina!=""){if (isset($_POST['tipocucina']))
$where_clause .= " tipocucina='$tipocucina' AND ";}
if ($prenotazione!=""){if (isset($_POST['prenotazione']))
$where_clause .= " prenotazione='$prenotazione' AND ";}
if ($dehor!=""){if (isset($_POST['dehor']))
$where_clause .= " dehor='$dehor' AND ";}
if ($fumo!=""){if (isset($_POST['fumo']))
$where_clause .= " fumo='$fumo' AND ";}
if ($parking!=""){if (isset($_POST['parking']))
$where_clause .= " parking='$parkin' AND ";}
if ($cartecredito!=""){if (isset($_POST['cartecredito']))
$where_clause .= " cartecredito='$cartecredito' AND ";}
if ($linguaggio!=""){if (isset($_POST['linguaggio']))
$where_clause .= " linguaggio='$linguaggio' AND ";}
if ($animali!=""){if (isset($_POST['animali']))
$where_clause .= " animali='$animali' AND ";}
if ($condizionatore!=""){if (isset($_POST['condizionatore']))
$where_clause .= " condizionatore='$condizionatore' AND ";}
if ($handicapp!=""){if (isset($_POST['handicapp']))
$where_clause .= " handicapp='$handicapp' AND ";}
$where_clause .= " approvato='0' AND";
$where_clause .= " 0 = 0";
//Stampa Pagina Html principale
include "config.php";
$db = mysql_connect("$server", "$username", "$password");
mysql_select_db("$database",$db);
$sql_recipe = ("SELECT * from ristoranti WHERE provincia='$provincia' AND $where_clause");
// echo "$sql_recipe"; //mi stampa la query
$exec_recipe = mysql_query($sql_recipe) Or DIE (mysql_error());
$valori = mysql_num_rows($exec_recipe);
echo "
Ho trovato [b]$valori[/b] locali nella provincia di [b]$provincia[/b] con le caratteristiche da te richieste:
"; // mi stampa il numero di colonne presenti nel db
if($dehor!=""){echo "[img]img/dehor.gif[/img]";}
if($fumo!=""){echo "[img]img/fumo.gif[/img]";}
if($parking!=""){echo "[img]img/parking.gif[/img]";}
if($cartecredito!=""){echo "[img]img/cartecredito.jpg[/img]";}
if($linguaggio!=""){echo "[img]img/linguaggio.jpg[/img]";}
if($animali!=""){echo "[img]img/animali.gif[/img]";}
if($condizionatore!=""){echo "[img]img/condizionatore.gif[/img]";}
if($handicapp!=""){echo "[img]img/handicapp.gif[/img]";}
echo "
";
if(mysql_num_rows($exec_recipe) > 0 ) { // mi fa il controllo se ci sono dati nel db
while ($data = mysql_fetch_object($exec_recipe))
{
echo "<tr><td><h2>Profilo di $data->nomelocale</h2></td></tr>\n";
}
} else {
$sql_recipe = ("SELECT * from ristoranti WHERE $where_clause order by provincia ");
// echo "$sql_recipe"; //mi stampa la query
$exec_recipe = mysql_query($sql_recipe) Or DIE (mysql_error());
$valori2 = mysql_num_rows($exec_recipe);
echo "
";
echo "Con i dati da te inseriti risultano [b]$valori2[/b] locali in Italia"; // <----*** se io volessi fargli dividere l'output su piu pagine
echo "<table border=1>";
while ($data = mysql_fetch_object($exec_recipe))
{
echo "<tr><th scope=col>[url="index.php?id=$data->id&page=ristoranti>$data->nomelocale"]provincia)[/url]</th></tr>";
}
echo "</table>";
Echo "
";
Echo "
";
if($categoria!=""){echo "<a href=index.php?action=1&provincia=$provincia&categoria=$categoria&page=cercari2>Visualizza</a>";}
echo "</dl>" ;
}
?>
Io ho la mia bella paginetta php dove mi trova dei risultati nel db . Se volessi fargli fare piu pagine di stampa come faccio ???
Tipo subito mi stampa i primi 10 valori
poi ne ne tira fuori altri 10 cliccando su link prossimi
Chi mi aiuta ???