I am trying to make a dropdown list with values from a database, but when I try testing whether the value was taken in, I get nothing.
<select name = "student_id">
<option value="" >choose student</option>
$getnames = @mysqli_query($dbc, "SELECT student_id, first_name, last_name FROM students");
while ($row = mysqli_fetch_array($getnames))
?><option value = "<?php echo $row['student_id']; ?>">
<?php echo $row['student_id'] . ' ' .$row['first_name'] . ' '. $row['last_name'];
$studentid = trim($_POST['student_id']);
?><option value = "<?php $row['student_id']; ?>"> ^---missing echo
If you'd done any basic debugging, like a
view source of your generated html, you'd have seen that all of your option values are empty...
So, not, it's not the option refusing to store a value. it's doing EXACTLY what YOU told it to: send an empty/blank value to the server.