nschmutz Posted June 20, 2010 Share Posted June 20, 2010 I am an extreme beginner at this programming stuff and having some difficulty with my PHP class. I am trying to write a simple code that will use two pull down menus a Start and End with certain years available. Once they are selected and then submitted then I need to display a list of information between those years. I also need to display an error message if the end year selected is lower than the Start year. Here is the code I have written so far: <html> <head> </head> <p>Please enter the start and end years.</p> <form action="schmutz_02_03.php" method="post"> <?php if (isset($_POST['year'])) { $year = $_POST['year']; } $start = array('1974', '1978', '1982', '1986', '1990', '1994', '1998', '2002', '2006'); $end = array('1974', '1978', '1982', '1986', '1990', '1994', '1998', '2002', '2006'); echo 'Start year: <select name="year">'; foreach ($start as $value) { echo "<option value=\"$value\">$value</option>"; } echo '</select>'; echo '</br>End year: <select name="year">'; foreach ($end as $value) { echo "<option value=\"$value\">$value</option>"; if ($end < $start) { echo "The start year should be less than or equal to the end year."; } } echo '</select>'; echo '<input type="submit" name="submit" value="Go!" />'; ?> </form> </html> I deeply appreciate any help that can be given out. Link to comment https://forums.phpfreaks.com/topic/205345-array/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.