Values above selection form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Hodld
    New Member
    • Aug 2009
    • 2

    Values above selection form

    Hi,

    I'm creating a selection form with array data, using a for loop. This is my first time doing this, so it could be a pretty dumb mistake, but all the values end up printing on the line above the selection box, and the selection box comes up empty. Here's the code I'm using:

    Code:
    <?php 
    /* Builds the selection list array */
    $Distances = array("50","100","200","400","500","800","1000","1500","1650");
    echo "<form action = 'FormPrepared.php' method = 'POST'><table border='0'     width='50%'>";
    echo "<tr><td>Distance</td><td><select name='SelectedDistance'></td></tr>";
    $Counter = 0;
    for ($i=0;$i<sizeof($Distances);$i++)
    {
    echo "<option value = 'Distances[$i]'";
    if ($Counter == 0)
    {
    echo "selected";
    }
    echo "> $Distances[$i] </option> \n";
    $Counter++;
    }
    echo "</select>\n";
    Thanks for your help!
    Last edited by Markus; Aug 20 '09, 10:46 PM. Reason: Added [c
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    Ah. It's probably because you're closing the td and tr on line #5. Move those closing elements to line #17.

    Comment

    • Hodld
      New Member
      • Aug 2009
      • 2

      #3
      That fixed it, thank you!!

      Comment

      • Markus
        Recognized Expert Expert
        • Jun 2007
        • 6092

        #4
        Originally posted by Hodld
        That fixed it, thank you!!
        Glad to be of help, Hodld.

        See you around,
        Mark.

        Comment

        Working...