Actually I am working on an application that is in php. And I'm good with ASP.NET but not with PHP so require some help out here.
My application is an image gallery, and what I am doing here is, I am storing images in particular directories created at runtime, with a multi upload plugin and while creating a new album, the user will be prompted for just the name of the album, and then he selects all the images to be stored in that gallery. The data stored in the database will be the name of the gallery and the the relative path of the folder in which the images have been uploaded etc, while album art image and other images details are not added to the database.
On the other side I am looking for the output in such a way that the listing of the albums will be displayed from the database and one of the image from every image folder will be displayed as album art at random. When user clicks on that album art, the path of that album that was in the database will be passed as querystring and then he will be directed to the page displaying all the images for that relevant album. Here the server will scan all the images of the path taken from the query string and display all the images from that particular folder.
My codes:
$sql="Select ID, GalleryName, Path, CreateDate from imageGallery where IsActive=true";
$result=mysql_query($sql);
if (!$result) {
$message = 'Invalid query: ' . mysql_error() . "\n";
$message .= 'Whole query: ' . $query;
die($message);
}
while($albums_row = mysql_fetch_assoc($result)){
$albums[] = array(
'id' => $albums_row['ID'],
'name' => $albums_row['GalleryName'],
'path' => $albums_row['Path'],
'dates' => $albums_row['CreateDate']
);
}
foreach($albums as $album){
// please check if this thing is correct?
echo '<a href="showImage.php?galPath=' . $album["path"] . '"><img src="something"/> </a>';
// or any function that can work in this loop to call random image for each folder.
}
I have been successful in doing all the uploading and database adding things, and also displaying all the images of a particular folder on a web page. But my problem is to display a random image as an album art when I am displaying all the currently available albums. The data is fetched from the database, and server will scan for the "path" and get one image out of that path and display as album art.