
elkidogz
Members-
Posts
37 -
Joined
-
Last visited
Never
Profile Information
-
Gender
Not Telling
elkidogz's Achievements

Newbie (1/5)
0
Reputation
-
having it fetch the array is what made it work, the second array wasn't being built.
-
$array is what the function gets it's the folders directory <?php $files = scandir("allPICS",0); comparearrays($files); ?> this generates an array of file names (scroll up for an example of the values) inside the function its a variable called $array latest code revision <?php function comparearrays($array) { //$cleartables="TRUNCATE TABLE `tobeadded`"; //clears table notadded //$doitnow2=mysql_query($cleartables); //$query1="SELECT notinfilename FROM notadded"; //$result1 = mysql_query($query1); //$array=mysql_fetch_array($result1); print_r($array); $query2="SELECT fileName FROM pictures"; $result2 = mysql_query($query2); $rows = mysql_fetch_array($result2); print_r($rows); $result = array_diff($array, $rows); foreach ($result as $arrayElement)//rebuilds table notadded { $query="INSERT INTO tobeadded (tobeaddedfilename) VALUES ('$arrayElement')"; $doit = mysql_query($query); echo "File:".$arrayElement." was added to table tobeadded <br>"; } echo "function comparearrays is complete."; } $files = scandir("allPICS",0); print_r($files); //shows array $files (verify the array exists) comparearrays($files); //sends $files array to function comparearrays as $array mysql_close($con) ?>
-
when i do a print_r($result2); on the variable for my select it returns so i must not be getting that right... hmm how to set it up
-
yes, it's an array of all the files in a given folder, my last post had a function that inserts to a table off that, then i use that same list to compare again to a second table. <?php $files = scandir("allPICS",0);?> output
-
This function works fine. What i don't get is that the other one is basically doing the same thing, it has three arrays the first is provided, second is from a select, third is the difference of those two arrays... and then just insert it. <?php function insertarray($arrayName) { $con = mysql_connect("nope"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("nope", $con); $cleartable="TRUNCATE TABLE `notadded`"; //clears table notadded $doitnow=mysql_query($cleartable); foreach ($arrayName as $arrayElement)//rebuilds table notadded { if ($arrayElement != '.' && $arrayElement != '..')// don't want . and .. in array just file names { $query="INSERT INTO notadded (notinfilename) VALUES ('$arrayElement')"; $result = mysql_query($query); //echo "File:".$arrayElement." was added to the table notadded. <br>"; } } echo"function insertarray is complete.<br>"; }?>
-
no change in results...
-
<?php function comparearrays($array) { $con = mysql_connect("nope"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("nope", $con); $query2="SELECT fileName FROM pictures"; $result2 = mysql_query($query2); $result = array_diff($array, $result2); foreach ($result as $arrayElement)//rebuilds table notadded { $query="INSERT INTO tobeadded (tobeaddedfilename) VALUES ('$arrayElement')"; $doit = mysql_query($query); echo "File:".$arrayElement." was added to table tobeadded"; } echo "function comparearrays is complete."; } $files = scandir("allPICS",0); comparearrays($files); ?> basically i want to see that it gets into the foreach loop, which it isn't right now... i think it's messing up on the arrays (the bane of my existence is arrays) it runs it's part and completes. any advice?
-
Never mind the above code... i've updated it since then... <?php include('Gallery.php'); function insertarray($arrayName) { $con = mysql_connect("no no"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("nope", $con); $cleartable="TRUNCATE TABLE `notadded`"; //clears table notadded $doitnow=mysql_query($cleartable); foreach ($arrayName as $arrayElement)//rebuilds table notadded { if ($arrayElement != '.' && $arrayElement != '..')// don't want . and .. in array just file names { $query="INSERT INTO notadded (notinfilename) VALUES ('$arrayElement')"; $result = mysql_query($query); echo "File:".$arrayElement." was added to the table notadded. <br>"; } } } function comparearrays() { $con = mysql_connect("no no"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("nope", $con); $cleartable="TRUNCATE TABLE `tobeadded`"; //clears table tobeadded $doitnow=mysql_query($cleartable); $query1="SELECT notinfilename FROM notadded"; $result1 = mysql_query($query1); $query2="SELECT fileName FROM pictures"; $result2 = mysql_query($query1); $result = array_diff($result1, $result2); foreach ($result as $arrayElement)//rebuilds table tobeadded { $query="INSERT INTO tobeadded (tobeaddedfilename) VALUES ('$arrayElement')"; $doit = mysql_query($query); echo "File:".$arrayElement." was added to table tobeadded"; } echo "done"; } $files = scandir("allPICS",0); insertarray($files); comparearrays(); mysql_close($con) ?> it goes into both functions, but it only performs the first ones insert am i not doing the arrays right?... what's going on here?
-
because i have one table where people are going to be working on these files that will constantly be added to the folder, it never shrinks, it only gets bigger... the first table is the work done table they are adding information about a picture to a table that has the file name, like a title, notes, etc... the second table is just a dump of the files that are in the folder. a third table is being generated so that i can display the pictures that are in the folder but don't have any information on them yet... <?php function insertarray($arrayName) { foreach ($arrayName as $arrayElement) { if ($arrayElement != '.' && $arrayElement != '..')// don't want . and .. in array just file names { $con = mysql_connect("my info"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("DOH ", $con); $query="INSERT INTO notadded (notinfilename) VALUES ('$arrayElement')"; $result = mysql_query($query); echo "File:".$arrayElement." was added to the table. <br>"; } } } function comparearrays() { $query1="SELECT notinfilename FROM notadded"; $result1 = mysql_query($query1); $query2="SELECT fileName FROM pictures"; $result2 = mysql_query($query1); $result = array_diff($result1, $result2); $query="INSERT INTO tobeadded (tobeaddedfilename) VALUES ('$result')"; return($result); } $files = scandir("allPICS",0); insertarray($files); comparearrays(); printr $result; //wanna see the results ?>
-
<?php function insertarray($arrayName) { foreach ($arrayName as $arrayElement) { if ($arrayElement != '.' && $arrayElement != '..')// don't want . and .. in array just file names { $con = mysql_connect("my info"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("DOH ", $con); $query="INSERT INTO notadded (notinfilename) VALUES ('$arrayElement')"; $result = mysql_query($query); echo "File:".$arrayElement." was added to the table. <br>"; } } } $files = scandir("allPICS",0); insertarray($files); ?> Sorry but now, i'm having issues with this insert line, basically it only inserts 30 at a time, how can i make it continue? with a counter while loop or something? make it sleep? please help there are roughly 3000-5000 records in this folder all of them need to go into a table so i can compare them .
-
tyvm
-
ok, I'm going to have a select on two different tables, the difference i need to insert to a third, I can load the two up as arrays, but now i need compare the two arrays, and have the output entered into a third array so i can enter that one back into a table... suggestions? array 1 Touched files (select few from a HUGE of 5,000+ files) array 2 all files (from same folder) array 3 difference between the two
-
[SOLVED] How does one get a list of all files in a folder?
elkidogz replied to elkidogz's topic in PHP Coding Help
kewl thanks -
quick simple, need a list of all files (i have like 5k or so) in a folder, I need to add there names to a table I am doing this so i can compare two tables table 1. comments added to uploaded pics -finished pictures- table 2. no comments added yet to uploaded pics (so they can be commented on GET IT?) -unfinished pictures- All the pictures are in a single folder for the time being i'm going to be making a form based on the pictures that are on table 2 so that they can have comments and titles and file name added to table 1 (to be done still) but i need to know all the file names for the folder in question, i guess i could do it via cmd line ls or something like that, i'll get back to you.