jontic Posted April 11, 2009 Share Posted April 11, 2009 I am trying to create a drop down menu with php to select information from a mysql database. With the following query I get a list of the types that need to be in my drop down menu (I do get an error message): echo '<select name="searchtype">'; echo '<option value="">---Select---</option>'; $searchtype=$_POST['searchtype']; $submit=$_POST['submit']; // Database variable declaration $db_host = "localhost"; $db_user = "....."; $db_pass = "....."; $db_name = "....."; // Make DB connection $db = mysqli_connect($db_host, $db_user, $db_pass, $db_name); // Check DB connection if(!$db) { echo "Error: Could not connect to database. Please try again later."; exit(); } // Create a php file to display the following query in HTML. $query1 = "SELECT education FROM users GROUP BY education"; $result1 = mysqli_query($db, $query1); while($row = mysqli_fetch_array($result1)) { echo "<option value=\"".$row['education']."\">".$row['education']."\n</option>"; } echo '</select>'; echo '<input type="submit" value="Select" value="submit" />'; However, I cannot succeed to get the result (see query below) of the selection made in the drop down menu. $query2 = "SELECT name, surname, education FROM users WHERE education = "$searchtype"; Can anyone help me please?? Link to comment https://forums.phpfreaks.com/topic/153672-accessing-mysql-database-from-the-web-with-php-drop-down-menu/ Share on other sites More sharing options...
jackpf Posted April 11, 2009 Share Posted April 11, 2009 What's the error then? And what does this have to do with regex..? Link to comment https://forums.phpfreaks.com/topic/153672-accessing-mysql-database-from-the-web-with-php-drop-down-menu/#findComment-807549 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.