So there's a lot of people helping to create a drop down list in html and populating it with their database. I'm trying to do this and I found some php code to do it but it just doesn't work. I understand php, sql and html but just not how they combine together. What seems to be the problem is that after the first echo, the rest of the code is just outputted as code to the page and it doesn't do anything. This is the code:
<html>
<body>
<?php
mysql_connect('localhost', 'root', 'password');
mysql_select_db('FoodMatching');
$sql = "SELECT IngID, IngName FROM Ingredient Characteristics";
$result = mysql_query($sql);
echo "<select name='Ingredient Name'>";
while ($row = mysql_fetch_array($result)) {
echo "<option value='" . $row['IngName'] ."'>" . $row['IngName'] ."</option>";
}
echo "</select>";
?>
</body>
</html>
And what I see on the webpage is:
"; while ($row = mysql_fetch_array($result)) { echo "
" . $row['IngName'] ."
"; } echo ""; ?>
There's no errors/warnings that pop up so I don't know what the problem is. Thank you if you can help :)