1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
| <?php
function Loterie($debut,$quantite_elements,$nb_tirage)
{
$limite = $debut + $quantite_elements -1;
// création du tableau
$tab = range($debut,$limite);
// mélange du tableau
shuffle($tab);
// prend les $nb_tirage premiers
$tab_tirage = array_slice($tab, 0, $nb_tirage);
return $tab_tirage;
}
$debut = 1;
$quantite_elements = 20;
$nb_tirage = 8;
$numbers1 = Loterie($debut,$quantite_elements,$nb_tirage);
$debut = 21;
$numbers2 = Loterie($debut,$quantite_elements,$nb_tirage);
$debut = 41;
$numbers3 = Loterie($debut,$quantite_elements,$nb_tirage);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Loterie</title>
<script>
var tab_php1 = <?php echo json_encode($numbers1)?>;
var tab_php2 = <?php echo json_encode($numbers2)?>;
var tab_php3 = <?php echo json_encode($numbers3)?>;
function Affiche(i,tab,id){
i++;
if (typeof tab[i] != 'undefined')
{
setTimeout(function(){Affiche(i,tab,id)},1000);
var p = document.createElement("p");
var nombre = document.createTextNode(tab[i]);
p.appendChild(nombre);
document.getElementById(id).appendChild(p);
}
}
</script>
<style type="text/css">
.loto p {
float:left;
border:1px solid green;
background: #FFCC00;
color: black;
text-align: center;
width: 50px;
height: 45px;
font-weight: bolder;
font-size: 2em;
font-family: serif, Arial;
font-stretch: wider;
font-style: normal;
}
.loto {
clear:both;
}
</style>
</head>
<body onload="Affiche(-1,tab_php1,'mondiv1'),Affiche(-1,tab_php2,'mondiv2'),Affiche(-1,tab_php3,'mondiv3')">
<div class = "loto" id = "mondiv1" ></div>
<div class = "loto" id = "mondiv2" ></div>
<div class = "loto" id = "mondiv3" ></div>
</body>
</html> |
Partager