tags:

views:

44

answers:

2
<?php   
    $home = "/index.php";
    $aboutus = "/aboutus.php";
    $contact = "/contact.php";
    $contact_reply = "/contact_reply.php";

    $current = $_SERVER['REQUEST_URI'];

    if ($contact==$current)
    {
     print "&nbsp;";
    }
    else
      { 

       if (isset($_POST["op"])){
        $message = "";
        foreach ($HTTP_POST_VARS['myselect'] as $value)
        {
         $message .= $value;
         if($message=="2")
         {
          echo "number 2 is selected";
         }
         else
         {
          echo "number gay";
         }
        };

       }
       else {
       print '
         <form method="post" action ><input name="op" TYPE="hidden" VALUE="send">
         <select name="myselect[]" size="6" multiple="multiple">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
</select> 
           <select name="myselect[]"/>  
            <option value="#">-Select-</option>     
           <option title="car" value="car">Car</option>     
           <option value="USA">USA</option>  
          </select>
          <input type="image" src="images/go.gif" alt="Go" name="submit" id="submit" value="Submit"/>
         </form>
          ';}
       if($type=="car")
       {
        print '
         <form method="post" action="details.php" enctype="multipart/form-data"> 
         <table class="search_nav"> 
          <tr> 
           <td>
            <select name="manufacture" id="manufacture">
             <option value=" " selected="selected">Car Manufactures</option>
             <option value="audi">Audi</option> 
             <option value="fiat">Fiat</option>
             <option value="ford">Ford</option>                    
             <option value="land_rover">Land Rover</option>
             <option value="mini">Mini</option>
             <option value="toyota">Toyota</option>
             <option value="vauxhaul">Vauxhaul</option>
             <option value="volkswagen">Volkswagen</option>                            
            </select>
            </td> 
          </tr> 
          <tr> 
           <td colspan="2">
            <input type="image" src="images/go.gif" alt="Go" name="submit" id="submit" value="Submit"/>
           </td>
          </tr>
         </table> 

         </form>
         <form method="post" action="details_bikes.php" enctype="multipart/form-data"> 
         <table class="search_nav"> 
          <tr> 
           <td>
            <select name="manufacture" id="manufacture">
             <option value=" " selected="selected">Car Manufactures</option>
             <option value="ducati">Ducati</option> 
             <option value="fiat">Fiat</option>
             <option value="ford">Ford</option>                    
             <option value="land_rover">Land Rover</option>
             <option value="mini">Mini</option>
             <option value="toyota">Toyota</option>
             <option value="vauxhaul">Vauxhaul</option>
             <option value="volkswagen">Volkswagen</option>                            
            </select>
            </td> 
          </tr> 
          <tr> 
           <td colspan="2">
            <input type="image" src="images/go.gif" alt="Go" name="submit" id="submit" value="Submit"/>
           </td>
          </tr>
         </table> 
        ';
       }
       else
       {
       }
+1  A: 

When the form is submitted via POST, the select field will have the selected value sent to it via the $_POST array.

$value = $_POST['myselect']
echo $value;
Rocket
what so would something like this work? $value = ''; $_POST['myselect'] = $value;print $value;
Robert
That doesn't work, just tried it and nothing is being displayed :s
Robert
Guess I should fix the example. It should be `$value = $_POST['myselect']`
Rocket
A: 

what so would something like this work? $value = ''; $_POST['myselect'] = $value; print $value; – Robert 9 mins ago

That doesn't work, just tried it and nothing is being displayed :s – Robert 0 secs ago edit

Robert
Look at my modified example. I guess the original was a bit hard to understand. You need to set `$value` to `$_POST['myselect']`, not the other way around.
Rocket