Page 1 of 1

image directory stored in mysql

Posted: Tue Dec 22, 2009 9:32 pm
by hero789
Hi

I am trying to create an image gallery using the file directories for images that I have stored in a mysql database. I have other files of varying types also stored along with the images in the database. I could create a seperate image table but was wondering if their is a php method to only select images with image file extensions from the database.

Code: Select all

 
$query = "select corporate_details.corporate_details_id, corporate_details.corporate_details_title, corporate_details.corporate_details_file, file_type, file_size from corporate_details, published_details where corporate_details.corporate_details_id = published_details.corporate_details_id and
published_details.trainer_id = '$trainer_id' and corporate_details_title like '$files'";
$result = mysql_query($query) or die ("Error, query failed");
if(mysql_num_rows($result) ==0)
    {
    echo "Database is empty <br />";
    }
else
    {
    
while($row = mysql_fetch_array($result))
    {
    $mime_type= $row['file_type'];
    $document_id = $row['corporate_details_id'];
    $document_title = $row['corporate_details_title'];
    $document_content = $row['corporate_details_file'];
    $document_size = $row['file_size'];
   

Re: image directory stored in mysql

Posted: Tue Dec 22, 2009 9:40 pm
by hero789
Sorry I may not have made clear the content of the database.
corporate_details_title is the filename with extention where as corporate_details_file is the absolute directory path to the file, the database originally held the images, but i changed it as I preferred the use of directories, however I kept the field names.

Re: image directory stored in mysql

Posted: Wed Dec 23, 2009 10:44 am
by hero789
Hi
I fixed the problem, rather than create a database of mixed media, I created a table for images alone. Then simply sourced from this. It was an easier resolution.