<?php
$home = "/index.php";
$aboutus = "/aboutus.php";
$contact = "/contact.php";
$contact_reply = "/contact_reply.php";
$current = $_SERVER['REQUEST_URI'];
if ($contact==$current)
{
print " ";
}
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
{
}
views:
44answers:
2
Q:
How to get a form select to come back with the option value, to be then used with a PHP if statment?
+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
2010-08-19 20:05:03
what so would something like this work? $value = ''; $_POST['myselect'] = $value;print $value;
Robert
2010-08-20 08:58:36
That doesn't work, just tried it and nothing is being displayed :s
Robert
2010-08-20 09:08:26
Guess I should fix the example. It should be `$value = $_POST['myselect']`
Rocket
2010-08-20 13:25:00
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
2010-08-20 09:08:42
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
2010-08-20 13:26:01