is there a way that when I use the random function to get a list of random strings to display, it will stay even after i refreshed the page?
Such as this code:
session_start();
$a = array("red","green","blue","yellow","brown");
if ( ! isset($_SESSION['rand_val']) ) {
$_SESSION['rand_val'] = array_rand(array_flip($a));
}
try{
$db = $conn->prepare("Select Column from Table where `xColumn` = XX");
$db->execute();
while($row=$db->fetch(PDO::FETCH_OBJ)) {
//if returned 5 values from DB, then randomly generate 5 values.
echo $row->Column, "<br>";
echo ($_SESSION['rand_val']), "<br>";
}
} catch (PDOException $e) {
echo "Error: ".$e;
}
It only get the first value from the array and store into the session.