mysql - Storing dropdown box selection in php -
this question has answer here:
- using $_post select option value html 7 answers
have looked @ few examples - using $_post select option value html , how preselect html dropdown list php? , still bit stuck. want take user selection dropdown , store in php on page further use. using netbeans php.
userinterface.php
<form name="formname" method="post" action="index.php"> <div id='userlist'> <?php //get constants database require("database.php"); // opens connection mysql server $connection = mysqli_connect ($server, $username, $password); if (!$connection){ die('not connected : ' . mysqli_error()); } // set active mysql database $db_selected = mysqli_select_db($connection, $database); if (!$db_selected) { die ('can\'t use db : ' . mysqli_error($connection)); } $query = "select * route id = 1"; $result = mysqli_query($connection, $query); echo '<select name="list" style="width:400px;">'; while($r = mysqli_fetch_assoc($result)){ echo "<option =".$r['user'].">".$r['user']."</option>"; } echo '</select>'; ?> <input type="submit" id="button" value="get started!" />
map.php - trying store value , attempt use in query
$user = filter_input(input_post, "list"); $query = "select * route user = $user";
the error getting 'not formed' when try echo $user. don't think value $user coming through @ all.
your option tag not valid. need provide value attribute before "=".
Comments
Post a Comment