Janaka Posted October 21, 2013 Share Posted October 21, 2013 (edited) Hi,Ihave created a database which is hosted in a server. I need to filter certain data and display it on a webpage. The requirments are as followsMy table has columns (Career Field,Career Name,Name of University,Name of Program,Program,Zip Code,City,State,Website Link,E-Mail,First Name,Last Name,Address 1,Phone)So my webpage needs to have a combo box for user to select input as follows1.State (Drop-Down menu All the states in USA )2. City (user type the city)3. Career (Drop-Down menu[Flight Management ] [Engineering Air] [Traffic Control]4. Level of Education (Drop-Down menu [undergrad] [Grad] [POstgrad])When the user select all the values the webpage should filter the records for user entered values.....I have done the coding a bit ..help me how to pull data when user selects data from combo boxes.My code is as follows <!DOCTYPE html> <html> State <select name="state"> <option value="AL">AL</option> <option value="AK">AK</option> <option value="AZ">AZ</option> <option value="AR">AR</option> <option value="CA">CA</option> <option value="CO">CO</option> <option value="CT">CT</option> <option value="DE">DE</option> <option value="DC">DC</option> <option value="FL">FL</option> <option value="GA">GA</option> <option value="HI">HI</option> <option value="ID">ID</option> <option value="IL">IL</option> <option value="IN">IN</option> <option value="IA">IA</option> <option value="KS">KS</option> <option value="KY">KY</option> <option value="LA">LA</option> <option value="ME">ME</option> <option value="MD">MD</option> <option value="MA">MA</option> <option value="MI">MI</option> <option value="MN">MN</option> <option value="MS">MS</option> <option value="MO">MO</option> <option value="MT">MT</option> <option value="NE">NE</option> <option value="NV">NV</option> <option value="NH">NH</option> <option value="NJ">NJ</option> <option value="NM">NM</option> <option value="NY">NY</option> <option value="NC">NC</option> <option value="ND">ND</option> <option value="OH">OH</option> <option value="OK">OK</option> <option value="OR">OR</option> <option value="PA">PA</option> <option value="RI">RI</option> <option value="SC">SC</option> <option value="SD">SD</option> <option value="TN">TN</option> <option value="TX">TX</option> <option value="UT">UT</option> <option value="VT">VT</option> <option value="VA">VA</option> <option value="WA">WA</option> <option value="WV">WV</option> <option value="WI">WI</option> <option value="WY">WY</option> </select> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title></title> </head> <body> <?php $con = mysqli_connect("localhost", "username", "password", "table"); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } $result = mysqli_query($con, "SELECT * FROM College"); echo "<table border='1'> <tr> <th>Name</th> <th>Zip</th> </tr>"; while ($row = mysqli_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['First_Name'] . "</td>"; echo "<td>" . $row['Zip_Code'] . "</td>"; echo "</tr>"; } echo "</table>"; mysqli_close($con); ?> </body> </html> Edited October 27, 2013 by fenway code tags Quote Link to comment Share on other sites More sharing options...
Ch0cu3r Posted October 21, 2013 Share Posted October 21, 2013 The drop down list (<select></select>) needs to be enclosed in a form (<form></form>) that is the the body (<body></body>) of the webpage. How to add a form to a webpage https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Forms/My_first_HTML_form When a form is submitted you can accss the forms values using the $_GET or $_POST superglobals. Information on how PHP deals with forms http://php.net/manual/en/tutorial.forms.php http://uk3.php.net/manual/en/language.variables.external.php To filter data in your query you'd use the WHERE clause http://www.tutorialspoint.com/mysql/mysql-where-clause.htm Quote Link to comment Share on other sites More sharing options...
Barand Posted October 21, 2013 Share Posted October 21, 2013 Avoid spaces in column names. Don't duplicate values like University Name in every record. Normalize the data http://forums.phpfreaks.com/topic/273634-best-way-to-set-up-tables-when-multiple-values/?do=findComment&comment=1408360 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.