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 2 of 2
  1. #1
    Regular Coder Ludatha's Avatar
    Join Date
    Jan 2008
    Posts
    250
    Thanks
    51
    Thanked 5 Times in 5 Posts

    Cool Show directories

    Hi, on my website, you can store your own images, but I'm adding a folder option, how can I adapt this code to display all folders inside: " $folder = 'uploads/profile/'.$_GET['id']; "
    as well as the pictures (folders first then pictures)

    PHP Code:
    function profile_pictures()
    {
    // Check if user exists in the database
        
    $member $_GET["id"];
        
    $usernameid $_GET["id"];
        require_once(
    "classes/DbConnector.php");
        
    $db = new DbConnector();
        
    $db->connect();
        
    $query "SELECT * FROM members WHERE username='$member'";
        
    $result $db->query($query);
        
    $exists mysql_num_rows($result);  // Does the row exists?
        
    $folder 'uploads/profile/'.$_GET['id']; // specify images folder
        
    $images glob$folder '/*.*' ); // grab images
        
    $images array_chunk$images); // split it into rows of 3
        
        
    if($exists !="0"){ // User exists so display data
            
    $rows $db->fetchArray($result); // Get the profile from database
    echo "<table><tr><th class=\"top\" colspan=\"4\">Pictures</td></tr>
      <tr>
        <td colspan=\"4\"><div align=\"center\">
        <a href=\"member.php?id="
    ,$usernameid"\">Profile</a> | 
        <a href=\"friends.php?id="
    ,$usernameid"\">Friends</a> | 
        <a href=\"pictures.php?id="
    ,$usernameid"\">Pictures</a> | 
        <a href=\"videos.php?id="
    ,$usernameid"\">Videos</a> | 
        <a href=\"groups.php?id="
    ,$usernameid"\">Groups</a>
    </div></td>
      </tr>"
    // start table
    foreach ( $images as $row // iterate rows
    {
        echo 
    '<tr>';
        foreach ( 
    $row as $img // iterate columns
        
    {
            echo 
    '<center><td><p><a href="'$img'"><img src="'$img'" width="135px" height="101px" /></a></p>'// display image
            
            
    if($_GET["id"]!=$_SESSION["username"])
                    {
                        echo 
    ''// Display the link
                    
    }
                    else
                    {
                        echo 
    '<a href=member.php?set='$img'>Set as Profile Picture</a></td></center>'// Display the link
                    
    }
        }
        echo 
    '</tr>';
    }
    echo 
    '</table><br><p>To add photos go to your settings page!</p>'// end table 
            
    }


  • #2
    New to the CF scene
    Join Date
    Jul 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Try with ftp_nlist


  •  

    Posting Permissions

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