I have an HTML form containing a PHP section within it.
[php]
Connect to a databaseCreate Form
Choose a Module Mark Value
$con=mysqli_connect(‘localhost’, ‘username’, ‘password’) or die(‘No connection’);
mysqli_select_db($con, ‘labuser’) or die (‘test will not open’);
$query=“SELECT distinct studentnum from takes order by studentnum asc”;
//Run a query
//result_variable=mysqli_query(connection_variable, query_variable)
$result=mysqli_query($con, $query) or die (’ test will not open’);
//Fetch a result row as an associative array, a numeric array, or both
//- If an html tag contains a double quote, a backslash is used
while ($rows=mysqli_fetch_array($result)){
echo “<option value=”".$rows[0]."">".$rows[0]."";
}
//echo “”;
// Close a connection
//mysqli_close(connection_variable)
mysqli_close($con);
?>
The table it is trying to use ‘takes’ table, to populate the dropdown box with the ‘studentnum’ column’s values in ascending order.
But when I try to run it, the following occurs in the browser. The dropdown box does not populate, and inbetween the unpopulated dropdown box and the “Submit” button is the following:
"; // Close a connection //mysqli_close(connection_variable) mysqli_close($con); ?>
What have I missed that is causing no values to populate the dropdown box? And for PHP code to spill onto the HTML form?
Any help much appreciated. Thanks.