commit c5e5bbaaddbb494ebd46a24e7ed169dbcba50d26 parent 37091e591b521ac6c8b7e25dbca244f4717ab82a Author: David Liotta <liottad6@students.rowan.edu> Date: Mon, 17 Dec 2018 19:44:26 -0500 Added a 'Feeling lucky?' button to navbar This new button will bring a user to a random survey to take Diffstat:
M | website/res/navbar.php | | | 6 | ++++++ |
1 file changed, 6 insertions(+), 0 deletions(-)
diff --git a/website/res/navbar.php b/website/res/navbar.php @@ -5,6 +5,11 @@ if (isset($_SESSION['username'])) { } else { $profile = "Profile"; } + +$sql = "SELECT survey_id FROM survey ORDER BY RAND() LIMIT 1;"; +$result = mysqli_query($connect, $sql) or die(mysqli_error($connect)); +$feelinLucky = mysqli_fetch_assoc($result); +$luckyUrl = "takesurvey.php?sid=" . $feelinLucky['survey_id']; ?> <style> @@ -42,6 +47,7 @@ if (isset($_SESSION['username'])) { <a href="directory.php" target=""> Surveys </a> <a href="createsurvey.php" target=""> Create a Survey </a> <a href="profile.php" target=""> <?php echo $profile; ?> </a> + <a href="<?php echo $luckyUrl?>" target=""> Feeling Lucky? </a> </div> <br><br> </div>