0

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>&nbsp;</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>"; 
?>
3
Contributors
6
Replies
8
Views
10 Years
Discussion Span
Last Post by artiry
0

Hi

Yes i am connecting to the server in functions.php, its working fine, when i upload the files, and press submit the info displays immediate, regardless what i choose in the drop down, thats the problem im having.

Thanks for looking at it.

0

Hi artiry,
Its pretty hard to figure out whats happening from just the code you provided. Maybe functions.php should be posted also.

0

Hi

Thats problem i have, i want to select from the dropdown, then submit.

Then all will show from that selection, i do not know how to let the dropdown interact with the sql, once i can one then i can modify it to work with other options

Thanks

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.