Beispiel #1
0
}
$SQL_LIMIT_VOTED = 40;
$SQL_LIMIT_ALL = 10;
$SQL_SEXO = isset($_GET["sexo"]) && preg_match('/^[HM]$/', $_GET["sexo"]) ? "'" . $_GET["sexo"] . "'" : "'H'";
$SQL_USER = isset($_GET["user"]) ? "'" . $_GET["user"] . "'" : "'Dan'";
$SQL_FREQ_MAX = isset($_GET["freqMax"]) && is_numeric($_GET["freqMax"]) ? " AND frecuencia <=" . (double) $_GET["freqMax"] : "";
$SQL_FREQ_MIN = isset($_GET["freqMin"]) && is_numeric($_GET["freqMin"]) ? " AND frecuencia >=" . (double) $_GET["freqMin"] : "";
$SQL_COMP_NAM = !isset($_GET["multiName"]) ? " AND nombre not like '% %'" : "";
$SQL_COUNT = isset($_GET["count"]) ? true : false;
$query1 = "SELECT n.id, n.nombre " . " from votos v " . " left join nombres n on v.idName like n.id " . " where v.user like {$SQL_USER} " . " and n.sexo like {$SQL_SEXO} " . $SQL_FREQ_MIN . $SQL_FREQ_MAX . $SQL_COMP_NAM . " order by rand() " . " limit {$SQL_LIMIT_VOTED}";
$query2 = "SELECT id, nombre " . " from nombres " . " where sexo like {$SQL_SEXO} " . $SQL_FREQ_MIN . $SQL_FREQ_MAX . $SQL_COMP_NAM . " order by rand() " . " limit {$SQL_LIMIT_ALL}";
//Si se realiza una consulta de número de nombres disponible, se redirige la consulta a getCount.php
if ($SQL_COUNT) {
    header("Location: ./getCount.php?" . $_SERVER['QUERY_STRING']);
    exit;
}
$items = array();
$mysqli = new mysqli("localhost", "names", "como1cerda=)", "names") or die('Could not connect to the database server' . $mysqli->connect_error);
//obtenemos una sublista de nombres votados
queryToArray($mysqli, $query1, $items);
//obtenemos una sublista de nombres (votados y no votados)
queryToArray($mysqli, $query2, $items);
$mysqli->close();
//randomizamos el order
shuffle_with_keys($items);
//formateamos la salida
$string = '';
foreach ($items as $k => $v) {
    $string .= $k . ":" . $v . ";";
}
echo htmlspecialchars(substr($string, 0, -1));
Beispiel #2
0
while ($row = mysql_fetch_array($result)) {
    if ($row['num'] > 5) {
        $tags[$row['tag']] = $row['num'];
    }
}
if (count($tags) > 0) {
    shuffle_with_keys($tags, 12);
}
$result = mysql_query("select tag, count(tag) as num from imdbtags group by tag order by num DESC LIMIT 16");
while ($row = mysql_fetch_array($result)) {
    if ($row['num'] > 5) {
        $tags[$row['tag']] = $row['num'];
    }
}
if (count($tags) > 0) {
    shuffle_with_keys($tags, 18);
}
// change these font sizes if you will
$max_size = 200;
// max font size in %
$min_size = 100;
// min font size in %
// get the largest and smallest array values
$max_qty = max(array_values($tags));
$min_qty = min(array_values($tags));
// find the range of values
$spread = $max_qty - $min_qty;
if (0 == $spread) {
    // we don't want to divide by zero
    $spread = 1;
}