MySQL Forums
Forum List  »  PHP

Re: Using images with php and sql
Posted by: Michael Hendry
Date: October 24, 2011 06:39AM

I've done this sort of thing for my Rotary Club's website, which includes a report of each meeting, with images of the speakers if they're sufficiently photogenic.

I save the images in their own folder on the website, named according to the dates of the meeting, for example "2011-10-23.jpg", but any unique name will do. I append an alphabetic character for additional images from that date ("2011-10-23a.jpg", "2011-10-23b.jpg" etc), and display them in alphabetical order if there is more than one image per meeting. The advantage in naming the files in this way is that I can immediately see in a directory listing that I've missed one out.

I have a table for the images in my database, which links them to individual meetings, and also provides a caption and alternative text for each.

--
-- Table structure for table `tbl_m_images`
--

DROP TABLE IF EXISTS `tbl_m_images`;
CREATE TABLE IF NOT EXISTS `tbl_m_images` (
  `m_images_key` bigint(20) NOT NULL AUTO_INCREMENT,
  `file_name` varchar(255) NOT NULL DEFAULT '',
  `caption` varchar(255) DEFAULT NULL,
  `alternative_text` varchar(255) DEFAULT NULL,
  `meeting_key` bigint(20) NOT NULL DEFAULT '0',
  PRIMARY KEY (`m_images_key`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=245 ;

I use PHP and HTML to display the detail of each meeting with its associated images as thumb-nails, with the option of a pop-up in higher resolution available if the image is double-clicked.

I can't see any advantage in not having an individual file for each image, but obviously the way you link the files up with the text will depend on the way you use the images.

Options: ReplyQuote


Subject
Written By
Posted
October 23, 2011 11:17PM
Re: Using images with php and sql
October 24, 2011 06:39AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.