Double Dropdown Submit ,PHP ,MYSQL

Reply

Join Date: Oct 2006
Posts: 4
Reputation: artiry is an unknown quantity at this point 
Solved Threads: 0
artiry artiry is offline Offline
Newbie Poster

Double Dropdown Submit ,PHP ,MYSQL

 
0
  #1
Oct 25th, 2006
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 WindsS,N,E,W,NW)
When the user clicks on the 1stdropdown and chooses a wind eg.S
Dropdown 2:four RegionsEAST,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:
=======
  1. <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post" >
  2. <table width="450" border="0" cellspacing="0" cellpadding="0">
  3. <tr>
  4. <td><b>Wind:</b></td>
  5. <td><select name="wind">
  6. <option>--Please Select--</option>
  7. <option>S</option>
  8. <option>SW</option>
  9. <option>N</option>
  10. <option>NW</option>
  11. <option>E</option>
  12. </select></td>
  13. </tr>
  14. <tr>
  15. <td><b>Region:</b></td>
  16. <td><select name="region">
  17. <option>--Please Select--</option>
  18. <option>West</option>
  19. <option>Easte</option>
  20. <option>South</option>
  21. <option>North</option>
  22. </select></td>
  23. </tr>
  24. <tr>
  25. <td>&nbsp;</td>
  26. <td><label>
  27. <input type="submit" name="Submit" value="Submit">
  28. </label></td>
  29. </tr>
  30.  
  31. </table>
  32. </form>
  33. -------------------------------------------------------------------------
  34. //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
  35. -------------------------------------------------------------------------
  36. <?php
  37. include("functions.php");
  38. Connect();
  39.  
  40. if($REQUEST_METHOD=="POST") {
  41.  
  42. }
  43.  
  44. if (!isset($query) || empty($query)){
  45. $query = "Select * from location ";
  46.  
  47. }
  48.  
  49. $query= stripslashes($query);
  50.  
  51. $result = mysql_query($query) or
  52. die( mysql_error() );
  53.  
  54. $number_cols = mysql_num_fields($result);
  55.  
  56. echo "<b>Query: $query</b>";
  57.  
  58. echo "<table width=500 border = 4>\n";
  59. echo "<tr align =center bgcolor=\"lightblue\">\n";
  60. for ($i=0; $i<$number_cols; $i++)
  61. {
  62.  
  63. echo "<th>" . mysql_field_name($result, $i). "</th>\n";
  64. }
  65. echo "</tr>\n";
  66.  
  67. while ($row = mysql_fetch_row($result)) {
  68.  
  69. echo "<tr valign = top>\n";
  70.  
  71. for ($i=0; $i<$number_cols; $i++)
  72. {
  73. if($i % 2){
  74. echo "<td bgcolor=lightgrey horizon>";
  75. }else{echo "<td bgcolor=white>";}
  76.  
  77. //echo "<td>";
  78.  
  79. if(!isset($row[$i])){
  80. echo "Null";
  81. }else
  82. {
  83. echo $row[$i];
  84. }
  85. echo "</td>\n";
  86. }
  87. echo "</tr>\n";
  88. }
  89. echo "</table>";
  90. ?>
Last edited by cscgal; Oct 25th, 2006 at 2:07 pm.
Reply With Quote Quick reply to this message  
Join Date: Jul 2004
Posts: 494
Reputation: Puckdropper is an unknown quantity at this point 
Solved Threads: 21
Puckdropper Puckdropper is offline Offline
Posting Pro in Training

Re: Double Dropdown Submit ,PHP ,MYSQL

 
0
  #2
Oct 25th, 2006
You're connecting to the server presumably in functions.php? How's that working?
www.uncreativelabs.net

Old computers are getting to be a lost art. Here at Uncreative Labs, we still enjoy using the old computers. Sometimes we want to see how far a particular system can go, other times we use a stock system to remind ourselves of what we once had.
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 4
Reputation: artiry is an unknown quantity at this point 
Solved Threads: 0
artiry artiry is offline Offline
Newbie Poster

Re: Double Dropdown Submit ,PHP ,MYSQL

 
0
  #3
Oct 26th, 2006
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.
Reply With Quote Quick reply to this message  
Join Date: Sep 2005
Posts: 1,083
Reputation: digital-ether is just really nice digital-ether is just really nice digital-ether is just really nice digital-ether is just really nice 
Solved Threads: 66
Moderator
digital-ether's Avatar
digital-ether digital-ether is offline Offline
Veteran Poster

Re: Double Dropdown Submit ,PHP ,MYSQL

 
0
  #4
Oct 26th, 2006
Hi artiry,
Its pretty hard to figure out whats happening from just the code you provided. Maybe functions.php should be posted also.
www.fijiwebdesign.com - web design and development and fun
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 4
Reputation: artiry is an unknown quantity at this point 
Solved Threads: 0
artiry artiry is offline Offline
Newbie Poster

Re: Double Dropdown Submit ,PHP ,MYSQL

 
0
  #5
Oct 26th, 2006
Hi

Here is a link where you can see what i wanna do, like click on a wind and region, then all the correct info displays.

function.php just connects to database for now.
http://firecracker.co.za/surf/surf_test.php

Thanks
Reply With Quote Quick reply to this message  
Join Date: Sep 2005
Posts: 1,083
Reputation: digital-ether is just really nice digital-ether is just really nice digital-ether is just really nice digital-ether is just really nice 
Solved Threads: 66
Moderator
digital-ether's Avatar
digital-ether digital-ether is offline Offline
Veteran Poster

Re: Double Dropdown Submit ,PHP ,MYSQL

 
0
  #6
Oct 26th, 2006
You'll need to post the code where you put together the mysql query. At the moment all that can be seen is $query.

www.fijiwebdesign.com - web design and development and fun
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 4
Reputation: artiry is an unknown quantity at this point 
Solved Threads: 0
artiry artiry is offline Offline
Newbie Poster

Re: Double Dropdown Submit ,PHP ,MYSQL

 
0
  #7
Oct 26th, 2006
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
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 4688 | Replies: 6
Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC