$connection = mysql_connect($db_host, $db_username, $db_password); if (!$connection){ die ("Could not connect to the database:
". mysql_error()); } $db_select = mysql_select_db($db_database); if (!$db_select){ die ("Could not select the database:
". 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:
". 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 " "; echo "" ; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo" "; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo " "; echo " "; echo " "; echo ""; echo " "; echo " "; echo " "; echo " "; echo ""; echo " "; echo "
"; echo "$nombre"; echo "
"; echo "$direccion"; echo ""; echo "\"\""; echo "
"; echo "Tel.: $tel"; echo ""; echo "
"; echo "Entrega a Domicilio?: $entrega"; echo "
"; echo "Descripción: $descripcion"; echo ""; echo "
"; echo "Horario: $horario"; echo ""; echo "
"; echo ""; echo " "; echo ""; echo ""; echo "
"; echo ""; echo "Detalles: $detalles"; echo ""; echo "
"; echo "
"; echo ""; echo "Rating: $rating"; echo " "; echo "
"; echo "
"; echo ""; } /** PAGES MENU **/ if ($pageno == 1) { echo " [PRIMERA ANTERIOR "; } else { echo " PRIMERA "; $prevpage = $pageno-1; echo " ANTERIOR "; } echo " ( Page $pageno de $lastpage ) "; if ($pageno == $lastpage) { echo " SIGUIENTE ULTIMA "; } else { $nextpage = $pageno+1; echo " SIGUIENTE "; echo " ULTIMA "; /** END PAGES MENU **/ } // Close the connection mysql_close($connection);