I have a set of png images (16x16) stored in a folder that's on my web server. Path: c:/wamp/www/website/images/flags . These images represent the different flags of the world's countries.
I want to have access to these images dynamically when I'll output the list of countries and their respective flags in a table through a PHP script.
In my database I have created the following table
CREATE TABLE country (
ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
countryCode CHAR(2) NOT NULL,
countryName VARCHAR (50) NOT NULL,
phoneCode CHAR (3) NOT NULL,
imagePathName VARCHAR (254) NOT NULL,
PRIMARY KEY(ID)
) ENGINE = InnoDB;
How does image referencing work in such a case? Do I store the path just like any CSS or HTML ?
Should I have to store a path, do I simply add it in the following form:
INSERT INTO country VALUES ('', 'CD',
'Democratic Republic of Congo, '243', 'c:/wamp/www/website/images/flags/cd.png')
or must I have a column with a BLOB data type. Should that be the case how will the INSERT statement look like ?
Following Mahesh's suggestion:
Here's the code
In my table I have three main columns which are countryCode, countryName and filename. I inserted a few values such as:
The while() loop displays the content of the MySQL table.
In the first column of the HTML table the name of the country is displayed through:
In the second column of the HTML table the file name of the flag that represents that country is printed inside a URL link:
The names of the countries and flags are displayed dynamically. Exactly what I needed.