I am trying to create a HMTL select box which populates from a table in a SQL database.
This is my test code:
<head>
</head>
<body>
<?php
mysql_connect('localhost', 'root', 'apassword');
mysql_select_db('webforms');
$sql = "SELECT site FROM sites_rcs";
$result = mysql_query($sql);
echo "<select name='sub1'>";
while ($row = mysql_fetch_array($result)) {
echo "<option value '" . $row['site'] ."'>" . $row['site'] ."</option>";
}
echo "</select>"
</body>
When I open this page in a web browser I get this result:
"; while ($row = mysql_fetch_array($result)) { echo "" . $row['site'] .""; } echo ""
I have tried rewriting the code from various examples provided on the internet: https://www.youtube.com/watch?v=IVl5GPpMJsY http://www.yourwebskills.com/mysqldropdown.php
When I run the query SELECT site FROM sites_rcs
in phpMyAdmin it returns the values in a list.
Any ideas?
`. and change `echo "" ` to `echo "";`
– Adam Azad Nov 11 '15 at 10:35