I have created a simple database designed to accept domains and their associated TLD values:
CREATE TABLE domains(name VARCHAR(50) NOT NULL, PRIMARY KEY(name), tld ENUM('.com', '.net', '.info', '.org', '.co.uk', '.co', '.biz', '.info', '.de', '.me', '.nl', '.it', '.ch', '.li', '.us', '.name', '.ws'));
...and I now need to display a form with a field for the domain name to be entered manually, with the TLD selected from a drop-down menu. - Fine, no problem there ...only I cannot find a way to make the TLDs display within the dropdown menu.
The database connection has been tested, - works fine, - and I have spent two days putting together my own statements and mixing and matching with examples from online guides (including the MySQL documentation), eg:
mysql_connect("$s", "$u", "$p") or die(mysql_error('The Database Credentials Are A Bit Funky...'));
mysql_select_db("$d") or die(mysql_error('The Database Is Flaky, Too...'));
$query = "SELECT name,tld FROM domains";
$result = mysql_query($query) or die(mysql_error());
$dropdown = "<select name='extension'>";
while($row = mysql_fetch_assoc($result)) {
$dropdown .= "\r\n<option value='{$row['name']}'>{$row['tld']}</option>";
}
$dropdown .= "\r\n</select>";
echo $dropdown;
...and...
mysql_connect("$s", "$u", "$p") or die(mysql_error('The Database Credentials Are A Bit Funky...'));
mysql_select_db("$d") or die(mysql_error('The Database Is Flaky, Too...'));
$query="SELECT name, tld FROM domains";
$result = mysql_query ($query) or die(mysql_error());
echo "<select name=category value=''></option>";
while($row = mysql_fetch_array($result)){
echo "<option value=$row[name]>$row[tld]</option>";
}
echo "</select>";
?>
...but I still cannot get any further than an empty dropdown box.
The idea, if I can get the TLDs to display, is for a visitor to the website I am working on to be able to enter a domain and to then select a TLD from the dropdown. - Can anyone offer any help on this, please?