I have a combobox where I need to have on the options names of files in a folder that aren't register in a mySQL database.
The code is:
if ($handle = opendir('../media')) {
$dbhost = 'HOST';
$dbuser = 'USER';
$dbpass = 'PASS';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
while (false !== ($entry = readdir($handle))) {
if ($entry != "." && $entry != "..") {
$sql = 'SELECT url FROM musics WHERE url="PREFIX_URL'.$entry.'"';
mysql_select_db('DATABASE_NAME');
$retval = mysql_query( $sql, $conn );
if(! $retval )
{
echo "<option value='".$entry."'>";
echo substr($entry,0,-4); //This extracts the extension
echo "</option><br />";
}
mysql_close($conn);
}
}
closedir($handle);
}
Database have a column URL on table MUSICS where the content of it on each row is equal to the PREFIX_URL/nameOfTheFile.extension
My problem is that the combobox shows options with names of files that are registered on the database... And this is what I don't want to happen.
Can anybody help me?