rendered paste body$connection = mysql_connect($db_host, $db_username, $db_password);
if (!$connection){
die ("Could not connect to the database: <br />". mysql_error());
}
$db_select = mysql_select_db($db_database);
if (!$db_select){
die ("Could not select the database: <br />". mysql_error());
}
if (isset($_GET['pageno'])) {
$pageno = (int)$_GET['pageno'];
} else {
$pageno = 1;
}
/** SELECT TABLE VARIABLE**/
$select = ' SELECT ';
$column = ' * ';
$from = ' FROM ';
$tables = ' `restaurantes` ';
$where = '';
/* Count number of rows for pagination. */
$count = $select.'COUNT(*)'.$from.$tables.$where;
$result = mysql_query($count);
$query_data = mysql_fetch_row($result);
$numrows = $query_data[0];
$rows_per_page = 10;
$lastpage = ceil($numrows/$rows_per_page);
if ($pageno < 1) {
$pageno = 1;
} elseif ($pageno > $lastpage) {
$pageno = $lastpage;
}
$limit = 'LIMIT ' .($pageno - 1) * $rows_per_page .',' .$rows_per_page;
$query = $select.$column.$from.$tables.$where.$limit;
/** QUERY EXECUTION**/
$result = mysql_query( $query );
if (!$result)
{
die ("Could not query the database: <br />". mysql_error());
}
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)){
$nombre = $row["nombre"];
$direccion = $row["direccion"];
$tel = $row["tel"];
$descripcion = $row["descripcion"];
$horario = $row["horario"];
$tipo = $row["tipo"];
$detalles = $row["detalles"];
$entrega = $row["Entrega"];
$rating = $row["rating"];
$pic = $row["pic"];
echo " <tr>";
echo "<td height=\"222\">" ;
echo "<table width=\"100%\" border=\"0\" cellpadding=\"2\" cellspacing=\"1\" class=\"border\">";
echo "<tr>";
echo "<td colspan=\"2\" bgcolor=\"#6666CC\" class=\"Rheading\">";
echo "$nombre";
echo "</td>";
echo "</tr>";
echo "<tr>";
echo "<td class=\"resttext\">";
echo "$direccion";
echo "</td>";
echo" <td width=\"34%\" rowspan=\"5\">";
echo "<img src=\"images/$pic\" width=\"150\" height=\"150\" alt=\"\">";
echo "</td>";
echo "</tr>";
echo "<tr>";
echo "<td class=\"resttext\">";
echo "<b>Tel.: </b> $tel";
echo "</span>";
echo "</td>";
echo "</tr>";
echo "<tr>";
echo "<td bgcolor=\"#eeeeee\">";
echo "<b>Entrega a Domicilio?: </b> $entrega";
echo " </td>";
echo " </tr>";
echo " <tr>";
echo " <td bgcolor=\"#eeeeee\" class=\"resttext\">";
echo "<b>Descripción: </b> $descripcion";
echo "</span>";
echo "</td>";
echo "</tr>";
echo " <tr>";
echo " <td height=\"34\" bgcolor=\"#eeeeee\" class=\"resttext\">";
echo "<b>Horario: </b> $horario";
echo "</span>";
echo "</td>";
echo " </tr>";
echo " <tr>";
echo "<td colspan=\"2\"><table width=\"100%\" border=\"0\" cellpadding=\"5\" cellspacing=\"1\">";
echo "<tr>";
echo " <td width=\"253\" height=\"34\" bgcolor=\"#6666CC\" class=\"text2\">";
echo "<span class=\"Rtext\">";
echo "Detalles: $detalles";
echo "</span>";
echo "<br>";
echo " </td>";
echo "<td width=\"143\" bgcolor=\"#6666CC\" class=\"Rtext\">";
echo "<font color=\"#FFFFFF\">";
echo "Rating: $rating";
echo " </font>";
echo "</td>";
echo "</tr>";
echo "</table>";
echo "</td>";
echo " </tr>";
echo "</table>";
echo "</td>";
}
/** PAGES MENU **/
if ($pageno == 1) {
echo " [PRIMERA ANTERIOR ";
} else {
echo " <a href='{$_SERVER['PHP_SELF']}?pageno=1'>PRIMERA</a> ";
$prevpage = $pageno-1;
echo " <a href='{$_SERVER['PHP_SELF']}?pageno=$prevpage'>ANTERIOR</a> ";
}
echo " ( Page $pageno de $lastpage ) ";
if ($pageno == $lastpage) {
echo " SIGUIENTE ULTIMA ";
} else {
$nextpage = $pageno+1;
echo " <a href='{$_SERVER['PHP_SELF']}?pageno=$nextpage'>SIGUIENTE</a> ";
echo " <a href='{$_SERVER['PHP_SELF']}?pageno=$lastpage'>ULTIMA</a> ";
/** END PAGES MENU **/
}
// Close the connection
mysql_close($connection);