I'm having a problem creating a dropdown list and populating it with information from a database. When I display the page below I get this PHP code displayed in place of the drop down menu:
"
\n"; while ($row = mysqli_fetch_array($result)) { $str .= '' . $row . '
' . "\n"; } $str .= ''; echo $str ?>"
<html>
<head><link rel="stylesheet" type="text/css" href="styles.css" />
<title>Add A New Game to the Database</title</head>
<body>
<h3>Add A New Game to the Database</h3>
<form enctype="multipart/form-data" action="process_games.php" method="post">
<p><table border=0>
<TR>
<TD>Select A System</TD>
<TD>
<?php
require_once ('mysqli_connect.php');
$sql = "select systemid, systemName
from systems
order by systemName";
$result = mysqli_query($dbc, $sql) or die( "Could not execute query: $query" );
$str = "<SELECT NAME=systemid><BR>\n";
while ($row = mysqli_fetch_array($result)) {
$str .= '<OPTION VALUE=' . $row['systemid'] . '>' . $row['systemName'] . '<BR>' . "\n";
}
$str .= '</SELECT>';
echo $str
?>
</TD>
</TR>
<TR>
<TD>Select A Genre</TD>
<TD>
<?php
require_once ('mysqli_connect.php');
$sql = "select genreid, genre
from genre
order by genre";
$result = mysqli_query($dbc, $sql) or die( "Could not execute query: $query" );
$str = "<SELECT NAME=genreid><BR>\n";
while ($row = mysqli_fetch_array($result)) {
$str .= '<OPTION VALUE=' . $row['genreid'] . '>' . $row['genre'] . '<BR>' . "\n";
}
$str .= '</SELECT>';
echo $str
?>
</TD>
</TR>
<TR>
<TD>What is the condtion of the game?</TD>
<TD>
<?php
require_once ('mysqli_connect.php');
$sql = "select conditionid, condition_name
from condition_tbl
order by condition_name";
$result = mysqli_query($dbc, $sql) or die( "Could not execute query: $query" );
$str = "<SELECT NAME=conditionid><BR>\n";
while ($row = mysqli_fetch_array($result)) {
$str .= '<OPTION VALUE=' . $row['conditionid'] . '>' . $row['condition_name'] . '<BR>' . "\n";
}
$str .= '</SELECT>';
echo $str
?>
</TD>
</TR>
<input type="hidden" name="MAX_FILE_SIZE" value="1000000">
<TR>
<TR>
<TD>Game Title:</TD>
<TD><input type="text" name="product_name" size="41"></TD>
</TR>
<TR>
<TD>Product Quantity:</TD>
<TD><input type="text" name="quantity" size="41"></TD>
</TR>
<TR>
<TD>Product Price:</TD>
<TD><input type="text" name="price" size="41"></TD>
</TR>
<TR>
<TD>Upload game image: </TD>
<TD><input type="file" name="filename" size="41"></TD>
</TR>
</table>
<BR><BR>
<input type="submit" value="Submit">
</form>
</body>
</html>