cyberspiritual Posted August 18, 2009 Share Posted August 18, 2009 Hi everyone, I'm trying to write a script to be able to delete picture file not used in my shop. I have 2 size of pictures..one is called the item number followed by -01_S.gif and another one called the item number followed by -01_L.gif So I wrote that: <?php $resource = mysql_connect(localhost, XXXXXXX, XXXXXXX); $db = mysql_select_db(XXXXXXXX, $resource) or die ("Couldn't select database."); $db; // open the current directory by opendir $handle=opendir("."); while (($file = readdir($handle))!==false) { $compteS = 0; $compteL = 0; $sqqql="SELECT * FROM products"; $answer = mysql_query($sqqql); while ($answer_data = mysql_fetch_array($answer) ) { $model = $answer_data['products_model']; $imageS = "$model-01_S.gif"; $imageL = "$model-01_L.gif"; if ($file!=$imageS) echo""; else $compteS=$compteS+1; if ($file!=$imageL) echo""; else $compteL=$compteL+1; } if ($compteS==0) echo"File $file should be deleted.<br>"; if ($compteL==0) echo"File $file should be deleted.<br>"; } closedir($handle); mysql_close($resource2); echo"finish"; ?> But when I run it, I get all file listed even if they are in my database... does anyone could suggest somehing? Thank's Link to comment https://forums.phpfreaks.com/topic/170779-finding-pictures-files-not-listed-in-my-mysql-database/ Share on other sites More sharing options...
cyberspiritual Posted August 20, 2009 Author Share Posted August 20, 2009 Thanks for moving it to the right section..anyone know what should I do? Link to comment https://forums.phpfreaks.com/topic/170779-finding-pictures-files-not-listed-in-my-mysql-database/#findComment-902231 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.