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?

To retrieve all allowed enum values you have to read the table definition. Use the "show create table" statement and parse it for the enum field definition.

I replied to this earlier, but the quick reply links don't work. - Even after logging in they just display the reply until you move away from the page, but don't add the reply to the thread. - Not good.

Anyway, thanks for your reply. Unfortunately, SHOW_CREATE_TABLE is no use for what I am trying to do, as there is no way of extracting the required information from it. - Used in a script it only serves to tell you what, in my case, I already know just by checking the database files themselves.

The only way of possibly obtaining the information using SHOW_CREATE_TABLE would be a hideously ugly and complicated hack 'n' slash with a combination of string functions, trim, preg_replace, and preg_match.

If you need to access and manipulate the tld data, a more appropriate solution would be to create a tld table, and instead store a foreign key to the correct tld in your domains table.