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
| <?php
session_start();
header('Content-type: text/html;charset=iso-8859-1');
$datejour = date("Y-m-d");
if(!empty($_POST))
{
$_SESSION['rando'] = $_POST;
}
$rand = trim($_SESSION['rando']['rando']);
$db = mysql_connect('localhost', '', '');
// on sélectionne la base
mysql_select_db('test',$db);
// on crée la requête SQL
$sql = "SELECT nom, prenom, newid FROM gghf_rando WHERE rando = '$rand' ORDER BY RAND() LIMIT 6";
// on envoie la requête
$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());
echo '<table style="width:30%" border="1" cellspacing="1" cellpadding="0">';
echo '<tr>
<td width="80px">NOM</td>
<td width="80px">PRENOM</td>
<td width="80px">Code barre</td>
</tr>';
// on fait une boucle qui va faire un tour pour chaque enregistrement
while($data = mysql_fetch_assoc($req))
{
// on affiche les informations de l'enregistrement en cours
echo '<tr>
<td width="80px">'.$data['nom'].'</td>
<td width="80px">'.$data['prenom'].' </td>
<td width="80px">'.$data['newid'].' </td>
</tr>';
}
echo '</table>';
?> |
Partager