Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: Looping script

  1. #1
    Regular Coder
    Join Date
    Mar 2005
    Posts
    156
    Thanks
    8
    Thanked 1 Time in 1 Post

    Looping script

    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):

    PHP Code:
    $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

  • #2
    Regular Coder
    Join Date
    May 2006
    Location
    Wales
    Posts
    820
    Thanks
    1
    Thanked 82 Times in 79 Posts
    If I understand you correctly, couldn't you just do this:

    PHP Code:
    $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


  • The Following 2 Users Say Thank You to Mwnciau For This Useful Post:

    JohnDubya (01-24-2008), ziggy1621 (01-24-2008)

  • #3
    Regular Coder
    Join Date
    Mar 2005
    Posts
    156
    Thanks
    8
    Thanked 1 Time in 1 Post
    well now, that wasn't as difficult as I made it.. lol

    Thanks


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •