...

View Full Version : Looping script



ziggy1621
01-24-2008, 04:20 PM
I've got folders that are created through an 'admin' panel on a client's website. When these folders are created, a reference is placed into a database for reference.

I need to write a script that loops through those folders by referencing them in the database and copying files from an 'update' folder so I don't have to manually upload 1 file to all the folders.

I'm not looking for a freebie, so please point me to a tutorial.

I'm guessing something like (gonna be very rough, just trying to get my thought process accross):



$aSQL = "SELECT DISTINCT directory FROM table";
$aQResult = mysql_query( $aSQL, $aDBLink );
if ( $aQResult == true )
{
while ( $aRow = mysql_fetch_array( $aQResult ) )
{
$directory=$aRow['directory'];
///here is where I'm lost.. guessing its gonna be something to the effect of creating an array then using foreach[]?
foreach ($directory as &$copyFolder) {
//long copy function here.. which I already have written
}



Again forgive my messiness.. just can't get my brain wrapped around this one

Mwnciau
01-24-2008, 05:05 PM
If I understand you correctly, couldn't you just do this:


$aSQL = "SELECT DISTINCT directory FROM table";
$aQResult = mysql_query( $aSQL, $aDBLink );
$directory = array();

if ( $aQResult == true )
{
while ( $aRow = mysql_fetch_array( $aQResult ) )
{
$directory[] = $aRow['directory'];
}
}

foreach ($directory as &$copyFolder)
{
//long copy function here.. which I already have written
}

ziggy1621
01-24-2008, 08:48 PM
well now, that wasn't as difficult as I made it.. lol

Thanks



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum