Jump to content

genome

Members
  • Posts

    8
  • Joined

  • Last visited

genome's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. The correct choice, which somehow combines the chosen $term with the $term_presidents array map, is displayed on the right side. How do i go about doing this?
  2. im stomped on when i click submit, it wont do anything . ad its not posting the answer on the form either .
  3. <?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); $session->$terms = $terms; /* Remaining Php handler code goes here */ if (isset($params->guess)) { $answer = $session->answer; $term = $session->term; $presidents = $params->presidents; $wrong = $session->wrong; $old_answer = $answer; if ($answer == $old_answer) { $wrong += 1; } $session->wrong = $wrong; $session->answer = $answer; $response = "Sorry wrong guess # $wrong ."; } else { // choose a random word $term = $terms[ mt_rand( 0, count($terms)-1 ) ]; $session->$term = $term; $wrong = 0; $session->wrong = $wrong; } ?> <!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; } form { margin: 10px 0; } .spacing { letter-spacing: .5em; /* Add more style rules */ </style> </head> <body> <a id="logout" href="logout.php">Log out</a> <a id =<?php echo $president;?></a> <h2>President Guesss Game</h2> <form action="program.php" method="get"> <button type="submit" name="reset" >New Game</button> </form> <!-- Add form and presentation code --> During the term <pre> <?php echo $term?> <pre> who was the U.S President? <select name="presidents"> <?php foreach ($presidents as $value): ?> <option <?php if ($value == $params->presidents) echo "selected" ?> ><?php echo $value?></option> <?php endforeach ?> </select> <input type="submit" name="guess" value="Guess" /> </form> </body> </html>
  4. figured it out nevermind.
  5. how can i sort by last name, for my list?
  6. yea i got that in place. Can you explain in lamens term how to go about creating the code for this program?
  7. I need help creating a basic php problem. It includes the use of array maps.
  8. 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?
  9. 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>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.