$username = "[cambia-esto]"; $password = "[cambia-esto]"; $hostname = "[cambia-esto]"; $dbh = mysql_connect($hostname, $username, $password) or die("Non se pode conectar ao Mysql"); $selected = mysql_select_db("[cambia-esto]",$dbh) or die("Non se pode seleccionar a base de patos"); // nota mental: comentar o codigo $from_where=""; if(isset($_GET["texto"])){ $texto = mysql_real_escape_string($_GET["texto"]); $from_where ="WHERE sitio LIKE '%".$texto."%'"; } $query = "SELECT sitio AS tag, COUNT(id) AS quantity FROM sitios2 ".$from_where." GROUP BY sitio ORDER BY sitio ASC"; $result = mysql_query($query); if(mysql_num_rows($result)==0) die("Non se atoparon topónimos, modifica o filtro. volver."); while ($row = mysql_fetch_array($result)) { $tags[$row['tag']] = $row['quantity']; } $max_tam = 400; $min_tam = 70; $max_ntags = max(array_values($tags)); $min_ntags = min(array_values($tags)); $campo = $max_ntags - $min_ntags; if (0 == $campo) { $campo = 1; } $pso = ($max_tam - $min_tam)/($campo); $limit=19; if(isset($_GET["limit"])){ $limit = $_GET["limit"]; } ?>