In the following code, I am trying to import a complete TLD list file, then display it in a select box, with the .COM being the default selection.
It works flawlessly except for the .COM being the default selection. Instead, its gets outputted like every other line instead of having the selected=“selected” inclusion.
I have been banging my head against a wall on this one. … i know it must be something simple but I just can not put my finger on it.
thanks in advance for any assistance.
<?php
$fp = fopen('http://path/to/file.txt','r');
if (!$fp) {
$fp = fopen('\PATH\TO\LOCAL\FILE.TXT','r');
if (!$fp)
{
echo "Unavailable</select></th></td></tr></table></div></font>";
echo "<script type='text/javascript'><!--";
echo "alert('this page is temorarily offline.nnPlease try a little later.');";
echo "document.location.replace(../);";
echo '//--></script></body></html>';
exit;
}
}
while (!feof($fp))
{
$tldname = fgets($fp, 1024);
$str = $tldname;
if ($str[0] <> "#")
{
echo "<option value='.$tldname' ";
if ($tldname=="COM")
{
echo "selected='selected'";
}
echo ">.$tldname</option>n";
$fp++;
}
}
fclose($fp);
?>