I am working on an application for our karate school and would like to get the technique names from the database, store them in an array in a random order and be able to click a button to move through the entire array one at a time.
I have thought about this in several different ways including just doing it randomly from the database which was pretty easy, but it pulls the same technique multiple times and I only want it done once.
Sample code below lists them all randomly just like it should and when I refresh the browser it creates a new list just like I want. Now I would like to know how I could display only one at a time and keep it in the browser until all of them have been gone through.
$sqlQuery= "Select * from Techniques Order BY Rand()";
$statement = $db->prepare($sqlQuery);
$statement->execute();
while($row = $statement->fetch(PDO::FETCH_ASSOC)):
$techniqueName = $row['Technique_name'];
?>
<ul>
<li><?php echo $techniqueName; ?></li>
</ul>
<?php endwhile; ?>
I really have no idea if this makes any sense. I would also like to stay away from javascript if possible, although that is not really a requirement. Basically it is a fun little game idea that would allow the students to practice without doing the same technique a bunch of times and missing other ones.
Any thoughts would be much appreciated.
array_unique($array)function to get rid of repetitive values.