...

View Full Version : Show directories



Ludatha
03-15-2008, 11:29 PM
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)


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, 4 ); // 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

}
}

Nenad91
03-16-2008, 12:32 AM
Try with ftp_nlist



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum