I've also tried it this way.
PHP Code:
function listInvoice() {
error_reporting(E_ALL);
$the_array = Array();
$handle = opendir('invoice');
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") { /* as descripted below: these "files" will not be added to the array */
$the_array[] = $file;
}
}
closedir($handle);
foreach ($the_array as $element) {
$filename = '$element';
if ($this->sql->Select("SELECT filename FROM ".$this->TABLES['invoice']." WHERE filename = '".$element."'")) {
$this->sql->Insert("INSERT INTO ".$this->TABLES['invoice']." (filename) VALUES ('".$element."')");
} else {
}
}
}
}
PHP Code:
if ($this->sql->Select("SELECT filename FROM ".$this->TABLES['invoice']." WHERE filename = '".$element."'")) {
Looks at database to see if the filename already exists, if it doesnt,
PHP Code:
$this->sql->Insert("INSERT INTO ".$this->TABLES['invoice']." (filename) VALUES ('".$element."')");
puts the filename into the database. And if does it
PHP Code:
echo "$element \n" ;
Ok, this does work, but not exactly how I wanted it.
It only selects the first database entry.
Basically, what I want it to do, is look at the database for a duplicate entry of $element.
If there is a duplicate entry, it does nothing.
If there isnt a duplicate entry, it inserts the $element
__________________
Websites Created;
warscope.com
ratepayers.org.nz
Last edited by lothop; 06-07-2005 at 02:43 AM..
|