1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
<?php
session_start();
try
{
$pdo_options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION;
$bdd = new PDO('mysql:host=mysql51-57.perso;dbname=', '', '', $pdo_options);
$reponse = $bdd->query('SELECT *, id FROM textealeatoire WHERE id != "'.$_SESSION['id'].'" ORDER BY rand() LIMIT 1,1');
if (isset($_SESSION['id'])) {
$_SESSION['id'] = array();
}
while ($donnees = $reponse->fetch()) {
$_SESSION['id'] = $donnees['id'];
echo $donnees['id'];
}
$reponse->closeCursor();
}
catch(Exception $e)
{
die('Erreur : '.$e->getMessage());
}
?> |
Partager