Hi to all :cheesy:
The Problem::-|
========
I was wondering if someone could perhaps help me with a problem i have for a while now. I want to use two dropdowns and a submit button.
Sounds pretty easy, but when php and mysql comes in, then it gets a bit sticky.
Thanks in advance, if someone can/will help.
--------------------------------------------------------------------------------
The Solution:;)
========
Dropdown 1:five Winds:(S,N,E,W,NW)
When the user clicks on the 1stdropdown and chooses a wind eg.S
Dropdown 2:four Regions:(EAST,WEST,NORTH,SOUTH)
When the user clicks on the 2nddropdown and chooses a region eg.West.
Then presses the submit button.
--------------------------------------------------------------------------------
The Idae::eek:
======
Now what must happen is that all the info from the database that connect those to options clicked must display.
I just do not know how "connect" dropdowns with the database.
And then a table must display with a lot of Locations that falls within what the user choosed.
input:Eg. S, West, SUBMIT
output:Eg. Africa(text) - This place is nice(text) - picture(img)
input: Eg. N, South, SUBMIT
output:Eg. America- This place is nice - picure
-------------------------------------------------------------------------------
Code Sofar::sad:
=======
<form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post" >
<table width="450" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><b>Wind:</b></td>
<td><select name="wind">
<option>--Please Select--</option>
<option>S</option>
<option>SW</option>
<option>N</option>
<option>NW</option>
<option>E</option>
</select></td>
</tr>
<tr>
<td><b>Region:</b></td>
<td><select name="region">
<option>--Please Select--</option>
<option>West</option>
<option>Easte</option>
<option>South</option>
<option>North</option>
</select></td>
</tr>
<tr>
<td> </td>
<td><label>
<input type="submit" name="Submit" value="Submit">
</label></td>
</tr>
</table>
</form>
-------------------------------------------------------------------------
//This is the code to display,connect to server, but this is not the way, it should work, it doesnt even connect with the dropdown
-------------------------------------------------------------------------
<?php
include("functions.php");
Connect();
if($REQUEST_METHOD=="POST") {
}
if (!isset($query) || empty($query)){
$query = "Select * from location ";
}
$query= stripslashes($query);
$result = mysql_query($query) or
die( mysql_error() );
$number_cols = mysql_num_fields($result);
echo "<b>Query: $query</b>";
echo "<table width=500 border = 4>\n";
echo "<tr align =center bgcolor=\"lightblue\">\n";
for ($i=0; $i<$number_cols; $i++)
{
echo "<th>" . mysql_field_name($result, $i). "</th>\n";
}
echo "</tr>\n";
while ($row = mysql_fetch_row($result)) {
echo "<tr valign = top>\n";
for ($i=0; $i<$number_cols; $i++)
{
if($i % 2){
echo "<td bgcolor=lightgrey horizon>";
}else{echo "<td bgcolor=white>";}
//echo "<td>";
if(!isset($row[$i])){
echo "Null";
}else
{
echo $row[$i];
}
echo "</td>\n";
}
echo "</tr>\n";
}
echo "</table>";
?>