High/Low Game
Try It! Visit RepoTechnologies/Software used: PHP, Bootstrap, MySQL, HTML5, CSS3, and PhpStorm
- Software Engineering 2 Project
- Target number is generated server-side using PHP and hidden from the player
- User account creation/authentication using a SHA256 hash algorithm and salted to protect player data
One particular challenge I faced during this project was displaying a high score table of the top 10 scores when the user won. I overcame this challenge by utilizing PHP to fetch data from my database and display it in a table using a while loop to create new rows for each score entry.
High Score Table Code
<tbody>
<?php
//Prepare select statement
$sql = "SELECT username,score,timestamp FROM HighScores ORDER BY score ASC LIMIT 10";
$result = mysqli_query($link,$sql);
$count = 1;
while($highScoreData = mysqli_fetch_array($result)){
echo "
<tr>
<th> scope='row'>" . $count . "</th>
<td>" . $highScoreData['username'] . "</td>
<td>" . $highScoreData['score']."</td>
<td>" . $highScoreData['timestamp'] . "</td>
</tr>
";
$count++;
}
?>
</tbody>