genome Posted March 4, 2014 Share Posted March 4, 2014 Hey everyone im new to the forum, Okay so I need some help and maybe snippets on helping me achieve creating a program. The goal of this is to create a game which has the user guess which U.S. President corresponds to a randomly chosen term in office. A term (in office) constitutes a time range in which the U.S. President was the same. It turns out that the range of years of the term corresponds to a single President, but not vice-versa, because there is one U.S. President who had two terms. Generate the random term with this statement: $term = $terms[ mt_rand( 0, count($terms)-1 ) ]; so this is what i have. NOTE: THE OTHER PROGRAM'S PHP FILES ARE MADE. <?php require_once "include/Session.php"; $session = new Session(); if (!isset($session->valid)) { require_once "login.php"; exit(); } require_once "include/presidents.php"; // this is the list of the terms $terms = array_keys($term_presidents); // this is the list of all names (duplicates removed), sorted by last name $presidents = array_unique(array_values($term_presidents)); usort($presidents, "byLastName"); /* DO NOT MODIFY THE ABOVE LINES !!!!! */ $params = (object) $_REQUEST; print_r($params); /* Remaining Php handler code goes here */ ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge"/> <title>Average Calculator</title> <style type="text/css"> body { padding: 20px; } #logout { position: absolute; top: 40px; right: 40px; } /* Add more style rules */ </style> </head> <body> <a id="logout" href="logout.php">Log out</a> <h2>President Guess Game</h2> <form action="program.php" method="get"> <button type="submit" name="reset" >New Game</button> </form> <!-- Add form and presentation code --> </body> </html> Quote Link to comment Share on other sites More sharing options...
requinix Posted March 4, 2014 Share Posted March 4, 2014 So what's your question? Quote Link to comment Share on other sites More sharing options...
genome Posted March 4, 2014 Author Share Posted March 4, 2014 how do i go about creating the form with a drop down box including the arrays what should my first steps be with this program code? Quote Link to comment Share on other sites More sharing options...
requinix Posted March 4, 2014 Share Posted March 4, 2014 The HTML for a dropdown box looks like <select name="name for this dropdown here"> <option value="value 1">Label 1</option> <option value="value 2">Label 2</option> <option value="value 3">Label 3</option> </select>The value should probably be an ID number for each president, such as the key from $presidents. The label would be, of course, their name. Can you get that in place? Quote Link to comment Share on other sites More sharing options...
Q695 Posted March 4, 2014 Share Posted March 4, 2014 Do a database check on the names, and there will be no problem. Quote Link to comment Share on other sites More sharing options...
genome Posted March 4, 2014 Author Share Posted March 4, 2014 (edited) The HTML for a dropdown box looks like <select name="name for this dropdown here"> <option value="value 1">Label 1</option> <option value="value 2">Label 2</option> <option value="value 3">Label 3</option> </select>The value should probably be an ID number for each president, such as the key from $presidents. The label would be, of course, their name. Can you get that in place? yea i got that in place. Can you explain in lamens term how to go about creating the code for this program? Edited March 4, 2014 by genome Quote Link to comment Share on other sites More sharing options...
Q695 Posted March 4, 2014 Share Posted March 4, 2014 While loop with a database to pull the data from for the president of various years.. Quote Link to comment Share on other sites More sharing options...
genome Posted March 6, 2014 Author Share Posted March 6, 2014 how can i sort by last name, for my list? Quote Link to comment Share on other sites More sharing options...
Solution genome Posted March 6, 2014 Author Solution Share Posted March 6, 2014 figured it out nevermind. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.