Jump to content

Loop inside a loop


Asheeown

Recommended Posts

I'm making something that is downloading files from a remote server, only downloading the ones without their name in the database

 

So far this is how I started it:

 

$Query = "SELECT Name FROM RawProcessed";
$SQL = mysql_query($Query) or die(mysql_error());

foreach($Files as $f) {
foreach($Processed = mysql_fetch_array($SQL) as $p) {
	extract($Processed);
	echo "$Name<br />";
}

}

 

All the FTP scripting is in my version of the code, this is just the checking part, I put a test echo out there, this should be echoing 2 names which are already put in the database, but almost 50 or 60 times because thats how many files are on the remote server, anything else inside the first foreach statement will echo about 50 times, which is correct.  Any reason why the second foreach statement is only going twice?

Link to comment
https://forums.phpfreaks.com/topic/39362-loop-inside-a-loop/
Share on other sites

1. File list is called from the remote server, thats what $Files is

2. I want to call the names of the already download files from a database table

 

So the file list goes through a foreach statement.  Then I want it to have an array of all the values of the column "Name" coming from my table in the database.  Then it can check the names against those of which are in the database already.

 

Is their any easier way of accomplishing this than what I have, which doesn't even work

Link to comment
https://forums.phpfreaks.com/topic/39362-loop-inside-a-loop/#findComment-189866
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.