Jump to content

Need some Guidance


genome

Recommended Posts

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 ) ];

igx3qx.png

 

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" 
<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>
 
Link to comment
https://forums.phpfreaks.com/topic/286686-need-some-guidance/
Share on other sites

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?

Link to comment
https://forums.phpfreaks.com/topic/286686-need-some-guidance/#findComment-1471391
Share on other sites

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?

Link to comment
https://forums.phpfreaks.com/topic/286686-need-some-guidance/#findComment-1471402
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.