Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Need help with a dropdown menu

Options
  • 11-09-2007 5:46pm
    #1
    Registered Users Posts: 15,431 ✭✭✭✭


    I've pretty basic html knowledge as is pretty obvious from my site so please forgive the murdering of html below ..

    I'm trying to make a drop down menu to choose monthly weather stats for a given year for my weather station , ie choose year then choose month.

    I found an example on a website but clearly its not working.
    <html>
    <head>
      <title> Annamoe Monthly Data </title>
      
      
    </head>
    
    <body>
    >
    <?php
    if(isset($_POST['post'])) {
    if (($_POST['Year'] == '2007') AND ($_POST['Month'] == 'January')) {
    header("Location: jan07.html"); }
    elseif (($_POST['Year'] == '2007') AND ($_POST['Month'] == 'Febuary')) {
    header("Location: feb07.html"); }
    elseif (($_POST['Year'] == '2007') AND ($_POST['Month'] == 'March')) {
    header("Location: mar07.html"); }
    elseif (($_POST['Year'] == '2007') AND ($_POST['Month'] == 'April')) {
    header("Location: apr07.html"); }
    if (($_POST['Year'] == '2007') AND ($_POST['Month'] == 'May')) {
    header("Location: may07.html"); }
    elseif (($_POST['Year'] == '2007') AND ($_POST['Month'] == 'June')) {
    header("Location: jun07.html"); }
    elseif (($_POST['Year'] == '2007') AND ($_POST['Month'] == 'July')) {
    header("Location: jul07.html"); }
    elseif (($_POST['Year'] == '2007') AND ($_POST['Month'] == 'August')) {
    header("Location: aug07.html"); }
    if (($_POST['Year'] == '2007') AND ($_POST['Month'] == 'September')) {
    header("Location: sep07.html"); }
    elseif (($_POST['Year'] == '2007') AND ($_POST['Month'] == 'October')) {
    header("Location: oct07.html"); }
    elseif (($_POST['Year'] == '2007') AND ($_POST['Month'] == 'November')) {
    header("Location: nov07.html"); }
    elseif (($_POST['Year'] == '2007') AND ($_POST['Month'] == 'December')) {
    header("Location: dec07.html"); }
    else { die("Error"); }
    exit;
    }
    ?>
    <form method='post' action='yourfile.php'>
    <select name="Year" Month="1"><option>2007</option></select>
    <br>
    <select name="Month" Month="1"><option>January</option><option>Febuary</option><option>March</option><option>April</option><option>May</option><option>June</option><option>July</option><option>August</option><option>September</option><option>October</option><option>November</option><option>December</option></select>
    <br>
    <input type='submit' name='post' value='Press here to view the relevant page'>
    </form>
    </body>
    
    </html>
    

    This obviously only opens "yourfile.php" rather than the one I want it too, does anyone know what I need to do please?

    Thanks.

    Have a weather station?, why not join the Ireland Weather Network - http://irelandweather.eu/



Comments

  • Registered Users Posts: 3,594 ✭✭✭forbairt


    Whats the name of this file ? ... index.php ? ... if so .. replace yourfile with index

    Next ... header function calls need to come before any part of the page is sent ... having <html> before your header("location...") stuff will break this ...

    Also your server will have to be able to handle php files ? .. (yes stating the obvious ... but I'm assuming it can here) ?
    <?php
    if(isset($_POST['post'])) {
    if (($_POST['Year'] == '2007') AND ($_POST['Month'] == 'January')) {
    header("Location: jan07.html"); }
    elseif (($_POST['Year'] == '2007') AND ($_POST['Month'] == 'Febuary')) {
    header("Location: feb07.html"); }
    elseif (($_POST['Year'] == '2007') AND ($_POST['Month'] == 'March')) {
    header("Location: mar07.html"); }
    elseif (($_POST['Year'] == '2007') AND ($_POST['Month'] == 'April')) {
    header("Location: apr07.html"); }
    if (($_POST['Year'] == '2007') AND ($_POST['Month'] == 'May')) {
    header("Location: may07.html"); }
    elseif (($_POST['Year'] == '2007') AND ($_POST['Month'] == 'June')) {
    header("Location: jun07.html"); }
    elseif (($_POST['Year'] == '2007') AND ($_POST['Month'] == 'July')) {
    header("Location: jul07.html"); }
    elseif (($_POST['Year'] == '2007') AND ($_POST['Month'] == 'August')) {
    header("Location: aug07.html"); }
    if (($_POST['Year'] == '2007') AND ($_POST['Month'] == 'September')) {
    header("Location: sep07.html"); }
    elseif (($_POST['Year'] == '2007') AND ($_POST['Month'] == 'October')) {
    header("Location: oct07.html"); }
    elseif (($_POST['Year'] == '2007') AND ($_POST['Month'] == 'November')) {
    header("Location: nov07.html"); }
    elseif (($_POST['Year'] == '2007') AND ($_POST['Month'] == 'December')) {
    header("Location: dec07.html"); }
    else { die("Error"); }
    exit;
    }
    ?>
    <html>
    <head>
      <title> Annamoe Monthly Data </title>
    </head>
    <body>
    <form method='post' action='index.php'>
    <select name="Year" Month="1"><option>2007</option></select>
    <br>
    <select name="Month" Month="1"><option>January</option><option>Febuary</option><option>March</option><option>April</option><option>May</option><option>June</option><option>July</option><option>August</option><option>September</option><option>October</option><option>November</option><option>December</option></select>
    <br>
    <input type='submit' name='post' value='Press here to view the relevant page'>
    </form>
    </body>
    </html>
    


  • Registered Users Posts: 15,431 ✭✭✭✭Supercell


    Forbairt you're a genius!!, that works great (smacking my head about the filename ...doh!).

    Wasnt aware of the placement within the file needing to come before the html tags either, thanks for pointing that out.

    Thanks very much :)

    Have a weather station?, why not join the Ireland Weather Network - http://irelandweather.eu/



  • Registered Users Posts: 3,594 ✭✭✭forbairt


    Longfield wrote:
    Forbairt you're a genius!!, that works great (smacking my head about the filename ...doh!).

    Wasnt aware of the placement within the file needing to come before the html tags either, thanks for pointing that out.

    Thanks very much :)

    no problem ... its what I'm here for ... er ... am ... er .. :D


  • Registered Users Posts: 455 ✭✭nellyshark


    Longfield wrote:
    I've pretty basic html knowledge as is pretty obvious from my site so please forgive the murdering of html below ..
    :)

    Hope you got your code sorted but that saying above had me laughing out loud. Thanks for brightening my evening :D


  • Registered Users Posts: 15,431 ✭✭✭✭Supercell


    nellyshark wrote:
    :)

    Hope you got your code sorted but that saying above had me laughing out loud. Thanks for brightening my evening :D

    Yep, it aint pretty but it works :)

    Somewhere, a web designer is weeping at what my site code looks like.

    Have a weather station?, why not join the Ireland Weather Network - http://irelandweather.eu/



  • Advertisement
  • Registered Users Posts: 3,594 ✭✭✭forbairt


    not weeping .... *rocks back and forth sucking on thumb* :D


  • Registered Users Posts: 6,511 ✭✭✭daymobrew


    Longfield wrote:
    Yep, it aint pretty but it works :).
    I see that you have graphical charts on the front page.
    I use PHP/SWF floating column charts on my M50 Weather page (just some fun grabbing data from nra.ie).


Advertisement