Bonjour à tous,
J'essaie de faire un petit tirage au sort pour Noël avec ma famille et j'aurais besoin de vos lumière car je bloque sur un petit truc...
Voici ce que je souhaite faire :
Un tirage au sort avec les propriétés suivantes :
- Le nom de celui qui fait le tirage ne peut pas être le nom à qui il doit faire un cadeau
- Si le participant a déjà tirer un nom alors il ne peut plus jouer
Voici ce que j'ai fait:
Mes tables :
Participants
--
-- Structure de la table `participants`
--
CREATE TABLE IF NOT EXISTS `participants` (
`num_participant` int(11) NOT NULL,
`id_participant` varchar(250) NOT NULL,
`nom` varchar(250) NOT NULL,
`prenom` varchar(250) NOT NULL,
`validation` varchar(3) NOT NULL,
KEY `num_participant` (`num_participant`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
Cadeaux
--
-- Structure de la table `cadeaux`
--
CREATE TABLE IF NOT EXISTS `cadeaux` (
`num_participant` int(11) NOT NULL,
`id_participant` varchar(250) NOT NULL,
`cadeau_pour` varchar(250) NOT NULL,
KEY `id_participant` (`id_participant`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
Page index.php pour l'accueil des participants
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Noël 2012 Chez Dom</title>
<style>
/*span {
font-size: 36px; background-color:#ffffff;
margin-top: 35px;
margin-left: -490px;
position: absolute;
left: 50%;
width: 980px;
height:500px;
box-shadow: 1px 1px 12px #555;
background: #d3d3d3 url('templates/design_ruffin_tillemont/back.png');
font-family: 'lucida grande',tahoma,verdana,arial,sans-serif;
text-align:center;
}
table {
vertical-align:middle;
}
.conteneur {
margin-left: -490px;
position: absolute;
left: 50%;
display: table-cell;
text-align: center;
vertical-align: middle;
width: 800px;
height: 600px;
background-color:#F00;
}
.conteneur * {
vertical-align: middle;
}
.conteneur span {
display: inline-block;
height: 100%;
}*/
html {
height: 100%;
}
body {
height: 100%;
width:100%;
margin: 0;
padding: 0;
background: #d61d25 url('img/christmas_background.jpg') no-repeat center center;
font-family: 'lucida grande',tahoma,verdana,arial,sans-serif;
font-size:24px;
background-size: 100% 100%;
}
#page-table {
height: 100%;
width: 100%;
border-collapse: collapse;
text-align: center;
}
#page-td {
height: 100%;
padding: 0;
vertical-align: middle;
text-align:center;
}
div#global {
width: 500px;
margin: auto;
text-align: center;
background:#fff;
padding:50px;
box-shadow: 1px 1px 12px #ccc;
margin-top:-170px;
}
</style>
</head>
<body>
<table id="page-table">
<tr>
<td id="page-td">
<div id="global">
<?php
$id_participant = $_GET['id_participant'];
$num_participant = $_GET['num_participant'];
//------------------------renomme le repertoire installation-------------------------------
//@rename("index.php","___index.php");
//@rename("--index.php","index.php");
//-----------------------------------------------------------------------------------------
//--------les includes des fonctions permettent le bon fonctionnement du site--------------
//include_once("haut.php");
//include_once("fonctions.php");
//-----------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------
$heures = 0; // les heures < 24
$minutes = 0; // les minutes < 60
$secondes = 4; // les secondes < 60
$annee = date("Y"); // par defaut cette année
$mois = date("m"); // par defaut ce mois
$jour = date("d"); // par defaut aujourd'hui
$redirection = 'tirage.php?id_participant='.$id_participant.'&num_participant='.$num_participant.''; // quand le compteur arrive à 0
// j'ai mis une redirection
/*******************************************************************************
* calcul des secondes
***************************************************************************/
$secondes = mktime(date("H") + $heures,
date("i") + $minutes,
date("s") + $secondes,
$mois,
$jour,
$annee
) - time();
?>
<script type="text/javascript">
var temps = <?php echo $secondes;?>;
var timer =setInterval('CompteaRebour()',1000);
function CompteaRebour(){
temps-- ;
j = parseInt(temps) ;
h = parseInt(temps/3600) ;
m = parseInt((temps%3600)/60) ;
s = parseInt((temps%3600)%60) ;
document.getElementById('minutes').innerHTML= (s<10 ? "0"+s : s);
//document.getElementById('minutes').innerHTML= (h<10 ? "0"+h : h) + ' h : ' +
// (m<10 ? "0"+m : m) + ' mn : ' +
// (s<10 ? "0"+s : s) + ' s ';
if ((s == 0 && m ==0 && h ==0)) {
clearInterval(timer);
url = "<?php echo $redirection;?>"
Redirection(url)
}
}
function Redirection(url) {
setTimeout("window.location=url", 500)
}
</script>
<?php
// la condition est que le nombre de seconde soit etre superieur a 24 heures
if ($secondes <= 3600*24) {
?>
<img src="img/cadeau-noel.jpg" style="padding-bottom:10px;" /><br />
Ton cadeau sera destiné à...
<div id="minutes" style="margin-top:15px;"></div>
<?php
}
//-----------------------------------------------------------------------------------------
//------------- affichage du bas de page --------------------------------------------------
// include "bas.php";
//-----------------------------------------------------------------------------------------
?>
</div><!-- #global -->
</td></tr></table>
</body>
</html>
Redirection au bout de 4 secondes sur le résultat du tirage (tirage.php) :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Noël 2012 Chez Dom</title>
<style>
/*span {
font-size: 36px; background-color:#ffffff;
margin-top: 35px;
margin-left: -490px;
position: absolute;
left: 50%;
width: 980px;
height:500px;
box-shadow: 1px 1px 12px #555;
background: #d3d3d3 url('templates/design_ruffin_tillemont/back.png');
font-family: 'lucida grande',tahoma,verdana,arial,sans-serif;
text-align:center;
}
table {
vertical-align:middle;
}
.conteneur {
margin-left: -490px;
position: absolute;
left: 50%;
display: table-cell;
text-align: center;
vertical-align: middle;
width: 800px;
height: 600px;
background-color:#F00;
}
.conteneur * {
vertical-align: middle;
}
.conteneur span {
display: inline-block;
height: 100%;
}*/
html {
height: 100%;
}
body {
height: 100%;
width:100%;
margin: 0;
padding: 0;
background: #d61d25 url('img/christmas_background.jpg') no-repeat center center;
font-family: 'lucida grande',tahoma,verdana,arial,sans-serif;
font-size:36px;
background-size: 100% 100%;
}
#page-table {
height: 100%;
width: 100%;
border-collapse: collapse;
text-align: center;
}
#page-td {
height: 100%;
padding: 0;
vertical-align: middle;
text-align:center;
}
div#global {
width: 500px;
margin: auto;
text-align: center;
background:#fff;
padding:50px;
box-shadow: 1px 1px 12px #ccc;
margin-top:-170px;
}
</style>
</head>
<body>
<?php
$mail = $_GET['id_participant'];
$num_participant = $_GET['num_participant'];
include_once('connection.php');
$conn = db_connect();
$sql = "SELECT * FROM participants WHERE validation !='OUI' AND id_participant != '$mail' AND num_participant ='$num_participant' ORDER by rand()";
$result = mysql_query($sql, $conn);
$row=mysql_fetch_array($result);
$cadeau_pour = $row['prenom'];
$validation = $row['validation'];
if($validation) {
?>
<table id="page-table">
<tr>
<td id="page-td">
<div id="global">
<?php
echo htmlentities($cadeau_pour);
if($result)
$conn = db_connect();
$sql = "UPDATE participants SET validation = 'OUI' WHERE id_participant = '$mail'";
$result = @mysql_query($sql, $conn);
$sql_cadeaux = "UPDATE cadeaux SET cadeau_pour = '$cadeau_pour' WHERE id_participant = '$mail'";
$result_cadeaux = @mysql_query($sql_cadeaux, $conn);
?>
<br />
<img src="img/cadeau-noel-ouvert.jpg" style="padding-top:10px;" />
</div><!-- #global -->
</td></tr></table>
<?php
}
else {
?>
<table id="page-table">
<tr>
<td id="page-td">
<div id="global">
Tu dois déjà faire un cadeau à <br />
Mais Le père Noël te remercie de ta générosité!
;-)
</div><!-- #global -->
</td></tr></table>
<?php
}
?>
</body>
</html>
Voilà j'ai essayé avec différentes conditions mais je n'arrive pas à faire en sorte que si la personne participante a déjà joué, un message lui indique qu'il ne peut plus jouer...
Les participants arrivent sur la page index avec un lien personnalisé du type : index.php?id_participant=
[email protected]&num_participant=3
Merci par avance pour votre aide.
Bonjour à tous,
J'essaie de faire un petit tirage au sort pour Noël avec ma famille et j'aurais besoin de vos lumière car je bloque sur un petit truc...
Voici ce que je souhaite faire :
Un tirage au sort avec les propriétés suivantes :
- Le nom de celui qui fait le tirage ne peut pas être le nom à qui il doit faire un cadeau
- Si le participant a déjà tirer un nom alors il ne peut plus jouer
Voici ce que j'ai fait:
Mes tables :
Participants
[sql]--
-- Structure de la table `participants`
--
CREATE TABLE IF NOT EXISTS `participants` (
`num_participant` int(11) NOT NULL,
`id_participant` varchar(250) NOT NULL,
`nom` varchar(250) NOT NULL,
`prenom` varchar(250) NOT NULL,
`validation` varchar(3) NOT NULL,
KEY `num_participant` (`num_participant`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;[/sql]
Cadeaux
[sql]--
-- Structure de la table `cadeaux`
--
CREATE TABLE IF NOT EXISTS `cadeaux` (
`num_participant` int(11) NOT NULL,
`id_participant` varchar(250) NOT NULL,
`cadeau_pour` varchar(250) NOT NULL,
KEY `id_participant` (`id_participant`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;[/sql]
Page index.php pour l'accueil des participants
[php]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Noël 2012 Chez Dom</title>
<style>
/*span {
font-size: 36px; background-color:#ffffff;
margin-top: 35px;
margin-left: -490px;
position: absolute;
left: 50%;
width: 980px;
height:500px;
box-shadow: 1px 1px 12px #555;
background: #d3d3d3 url('templates/design_ruffin_tillemont/back.png');
font-family: 'lucida grande',tahoma,verdana,arial,sans-serif;
text-align:center;
}
table {
vertical-align:middle;
}
.conteneur {
margin-left: -490px;
position: absolute;
left: 50%;
display: table-cell;
text-align: center;
vertical-align: middle;
width: 800px;
height: 600px;
background-color:#F00;
}
.conteneur * {
vertical-align: middle;
}
.conteneur span {
display: inline-block;
height: 100%;
}*/
html {
height: 100%;
}
body {
height: 100%;
width:100%;
margin: 0;
padding: 0;
background: #d61d25 url('img/christmas_background.jpg') no-repeat center center;
font-family: 'lucida grande',tahoma,verdana,arial,sans-serif;
font-size:24px;
background-size: 100% 100%;
}
#page-table {
height: 100%;
width: 100%;
border-collapse: collapse;
text-align: center;
}
#page-td {
height: 100%;
padding: 0;
vertical-align: middle;
text-align:center;
}
div#global {
width: 500px;
margin: auto;
text-align: center;
background:#fff;
padding:50px;
box-shadow: 1px 1px 12px #ccc;
margin-top:-170px;
}
</style>
</head>
<body>
<table id="page-table">
<tr>
<td id="page-td">
<div id="global">
<?php
$id_participant = $_GET['id_participant'];
$num_participant = $_GET['num_participant'];
//------------------------renomme le repertoire installation-------------------------------
//@rename("index.php","___index.php");
//@rename("--index.php","index.php");
//-----------------------------------------------------------------------------------------
//--------les includes des fonctions permettent le bon fonctionnement du site--------------
//include_once("haut.php");
//include_once("fonctions.php");
//-----------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------
$heures = 0; // les heures < 24
$minutes = 0; // les minutes < 60
$secondes = 4; // les secondes < 60
$annee = date("Y"); // par defaut cette année
$mois = date("m"); // par defaut ce mois
$jour = date("d"); // par defaut aujourd'hui
$redirection = 'tirage.php?id_participant='.$id_participant.'&num_participant='.$num_participant.''; // quand le compteur arrive à 0
// j'ai mis une redirection
/*******************************************************************************
* calcul des secondes
***************************************************************************/
$secondes = mktime(date("H") + $heures,
date("i") + $minutes,
date("s") + $secondes,
$mois,
$jour,
$annee
) - time();
?>
<script type="text/javascript">
var temps = <?php echo $secondes;?>;
var timer =setInterval('CompteaRebour()',1000);
function CompteaRebour(){
temps-- ;
j = parseInt(temps) ;
h = parseInt(temps/3600) ;
m = parseInt((temps%3600)/60) ;
s = parseInt((temps%3600)%60) ;
document.getElementById('minutes').innerHTML= (s<10 ? "0"+s : s);
//document.getElementById('minutes').innerHTML= (h<10 ? "0"+h : h) + ' h : ' +
// (m<10 ? "0"+m : m) + ' mn : ' +
// (s<10 ? "0"+s : s) + ' s ';
if ((s == 0 && m ==0 && h ==0)) {
clearInterval(timer);
url = "<?php echo $redirection;?>"
Redirection(url)
}
}
function Redirection(url) {
setTimeout("window.location=url", 500)
}
</script>
<?php
// la condition est que le nombre de seconde soit etre superieur a 24 heures
if ($secondes <= 3600*24) {
?>
<img src="img/cadeau-noel.jpg" style="padding-bottom:10px;" /><br />
Ton cadeau sera destiné à...
<div id="minutes" style="margin-top:15px;"></div>
<?php
}
//-----------------------------------------------------------------------------------------
//------------- affichage du bas de page --------------------------------------------------
// include "bas.php";
//-----------------------------------------------------------------------------------------
?>
</div><!-- #global -->
</td></tr></table>
</body>
</html>
[/php]
Redirection au bout de 4 secondes sur le résultat du tirage (tirage.php) :
[php]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Noël 2012 Chez Dom</title>
<style>
/*span {
font-size: 36px; background-color:#ffffff;
margin-top: 35px;
margin-left: -490px;
position: absolute;
left: 50%;
width: 980px;
height:500px;
box-shadow: 1px 1px 12px #555;
background: #d3d3d3 url('templates/design_ruffin_tillemont/back.png');
font-family: 'lucida grande',tahoma,verdana,arial,sans-serif;
text-align:center;
}
table {
vertical-align:middle;
}
.conteneur {
margin-left: -490px;
position: absolute;
left: 50%;
display: table-cell;
text-align: center;
vertical-align: middle;
width: 800px;
height: 600px;
background-color:#F00;
}
.conteneur * {
vertical-align: middle;
}
.conteneur span {
display: inline-block;
height: 100%;
}*/
html {
height: 100%;
}
body {
height: 100%;
width:100%;
margin: 0;
padding: 0;
background: #d61d25 url('img/christmas_background.jpg') no-repeat center center;
font-family: 'lucida grande',tahoma,verdana,arial,sans-serif;
font-size:36px;
background-size: 100% 100%;
}
#page-table {
height: 100%;
width: 100%;
border-collapse: collapse;
text-align: center;
}
#page-td {
height: 100%;
padding: 0;
vertical-align: middle;
text-align:center;
}
div#global {
width: 500px;
margin: auto;
text-align: center;
background:#fff;
padding:50px;
box-shadow: 1px 1px 12px #ccc;
margin-top:-170px;
}
</style>
</head>
<body>
<?php
$mail = $_GET['id_participant'];
$num_participant = $_GET['num_participant'];
include_once('connection.php');
$conn = db_connect();
$sql = "SELECT * FROM participants WHERE validation !='OUI' AND id_participant != '$mail' AND num_participant ='$num_participant' ORDER by rand()";
$result = mysql_query($sql, $conn);
$row=mysql_fetch_array($result);
$cadeau_pour = $row['prenom'];
$validation = $row['validation'];
if($validation) {
?>
<table id="page-table">
<tr>
<td id="page-td">
<div id="global">
<?php
echo htmlentities($cadeau_pour);
if($result)
$conn = db_connect();
$sql = "UPDATE participants SET validation = 'OUI' WHERE id_participant = '$mail'";
$result = @mysql_query($sql, $conn);
$sql_cadeaux = "UPDATE cadeaux SET cadeau_pour = '$cadeau_pour' WHERE id_participant = '$mail'";
$result_cadeaux = @mysql_query($sql_cadeaux, $conn);
?>
<br />
<img src="img/cadeau-noel-ouvert.jpg" style="padding-top:10px;" />
</div><!-- #global -->
</td></tr></table>
<?php
}
else {
?>
<table id="page-table">
<tr>
<td id="page-td">
<div id="global">
Tu dois déjà faire un cadeau à <br />
Mais Le père Noël te remercie de ta générosité!
;-)
</div><!-- #global -->
</td></tr></table>
<?php
}
?>
</body>
</html>
[/php]
Voilà j'ai essayé avec différentes conditions mais je n'arrive pas à faire en sorte que si la personne participante a déjà joué, un message lui indique qu'il ne peut plus jouer...
Les participants arrivent sur la page index avec un lien personnalisé du type :
[email protected]&num_participant=3
Merci par avance pour votre aide.