Skip to content

Instantly share code, notes, and snippets.

@mvnp
Created February 15, 2020 01:43
Show Gist options
  • Save mvnp/0b09aa23d2e16c23c709c2a0a8f30e89 to your computer and use it in GitHub Desktop.
Save mvnp/0b09aa23d2e16c23c709c2a0a8f30e89 to your computer and use it in GitHub Desktop.
<style>
.esquerda {
width: 30px;
height: 30px;
float: left;
border:1px solid #000;
}
.direita {
width: 200px;
height: 30px;
float: left;
border:1px solid #000;
}
</style>
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
/** @var [raw] [connection to database] */
$user = "root";
$pass = "123456";
$pdo = new PDO('mysql:host=localhost;dbname=lotofacil', $user, $pass, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
$sql_1 = $pdo->prepare("SELECT * FROM concurso ORDER BY numero_concurso DESC LIMIT 42");
$sql_1->execute();
$foreach = $sql_1->fetchAll(PDO::FETCH_ASSOC);
$all = [];
foreach ($foreach as $concursos => $c)
{
$implodeToCompare = implode(", ", $c);
$explodeToCompare = explode(", ", $implodeToCompare);
$all[] = $explodeToCompare;
}
// INICIALIZA DEZENAS
$d1 = 0; $d2 = 0; $d3 = 0; $d4 = 0;
$d5 = 0; $d6 = 0; $d7 = 0; $d8 = 0;
$d9 = 0; $d10 = 0; $d11 = 0; $d12 = 0;
$d13 = 0; $d14 = 0; $d15 = 0; $d16 = 0;
$d17 = 0; $d18 = 0; $d19 = 0; $d20 = 0;
$d21 = 0; $d22 = 0; $d23 = 0; $d24 = 0;
$d25 = 0;
foreach ($all as $agrupados => $agrup) {
foreach ($agrup as $agrupado => $final) {
$lotofacil = (($final == 1) ? $d1++ : "");
$lotofacil = (($final == 2) ? $d2++ : "");
$lotofacil = (($final == 3) ? $d3++ : "");
$lotofacil = (($final == 4) ? $d4++ : "");
$lotofacil = (($final == 5) ? $d5++ : "");
$lotofacil = (($final == 6) ? $d6++ : "");
$lotofacil = (($final == 7) ? $d7++ : "");
$lotofacil = (($final == 8) ? $d8++ : "");
$lotofacil = (($final == 9) ? $d9++ : "");
$lotofacil = (($final == 10) ? $d10++ : "");
$lotofacil = (($final == 11) ? $d11++ : "");
$lotofacil = (($final == 12) ? $d12++ : "");
$lotofacil = (($final == 13) ? $d13++ : "");
$lotofacil = (($final == 14) ? $d14++ : "");
$lotofacil = (($final == 15) ? $d15++ : "");
$lotofacil = (($final == 16) ? $d16++ : "");
$lotofacil = (($final == 17) ? $d17++ : "");
$lotofacil = (($final == 18) ? $d18++ : "");
$lotofacil = (($final == 19) ? $d19++ : "");
$lotofacil = (($final == 20) ? $d20++ : "");
$lotofacil = (($final == 21) ? $d21++ : "");
$lotofacil = (($final == 22) ? $d22++ : "");
$lotofacil = (($final == 23) ? $d23++ : "");
$lotofacil = (($final == 24) ? $d24++ : "");
$lotofacil = (($final == 25) ? $d25++ : "");
$new[1] = $d1;
$new[2] = $d2;
$new[3] = $d3;
$new[4] = $d4;
$new[5] = $d5;
$new[6] = $d6;
$new[7] = $d7;
$new[8] = $d8;
$new[9] = $d9;
$new[10] = $d10;
$new[11] = $d11;
$new[12] = $d12;
$new[13] = $d13;
$new[14] = $d14;
$new[15] = $d15;
$new[16] = $d16;
$new[17] = $d17;
$new[18] = $d18;
$new[19] = $d19;
$new[20] = $d20;
$new[21] = $d21;
$new[22] = $d22;
$new[23] = $d23;
$new[24] = $d24;
$new[25] = $d25;
}
}
$ordena = $new;
echo "<pre>";
print_r($ordena);
echo "<table border='1' style='margin-bottom:35px'>";
echo "<tr>";
for ($i = 1; $i < count($ordena)+1; $i++)
{
echo "<td>{$i}</td>";
}
echo "</tr>";
echo "<tr>";
for ($i = 1; $i < count($ordena)+1; $i++)
{
echo "<td>{$ordena[$i]}</td>";
}
echo "</tr>";
echo "</table>";
$par = 0;
$impar = 0;
$pares = 0;
$impares = 0;
foreach ($ordena as $key => $value)
{
echo "<div class='esquerda'>$key</div>";
echo "<div class='direita'>$value</div>";
echo "<div style='clear:both;display:block'></div>";
$pares = (($value % 2 === 0) ? $par++ : "");
$impares = (($value % 2 !== 0) ? $impar++ : "");
}
if(empty($pares)){
$pares = 25 - $impares;
} elseif(empty($impares)) {
$impares = 25 - $pares;
}
echo "<h2>São {$pares} dezenas pares</h2>";
echo "<h2>São {$impares} dezenas impares</h2>";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment