Table For Image Pointers
Posted: Fri Dec 09, 2011 11:41 pm
I'm relatively new to using sql to give you guys a heads up. I need to create a table that will store the pointer of an image that i've uploaded on my site. Eventually i'd like to be able to call a random image from the database and have the image displayed on it's own unique page.
I plan on renaming the images to incremented numbers, by just adding 1 to the highest id in the table that i'm trying to create.
I'm not really sure what should be in the table and what i'll need to specifically enter to create a new table. I think i'll be able to get away w/ the id, name, and pointer. But i'm not exactly sure what data type is required for the pointer.
Would this be correct?
CREATE TABLE uploaded_images (
id INT NOT NULL AUTO_INCREMENT,
name VARCHAR(30) NOT NULL,
type VARCHAR(30) NOT NULL,
PRIMARY KEY(id)
);
Based on that table would this be correct for the insert in my php? (assuming "rofl" is the image directory)
mysql_query("INSERT INTO uploaded_images (image_url)VALUES('rofl/".$_FILES["image"]["name"]."')") or die(mysql_error());
All help is greatly appreciate.
I plan on renaming the images to incremented numbers, by just adding 1 to the highest id in the table that i'm trying to create.
I'm not really sure what should be in the table and what i'll need to specifically enter to create a new table. I think i'll be able to get away w/ the id, name, and pointer. But i'm not exactly sure what data type is required for the pointer.
Would this be correct?
CREATE TABLE uploaded_images (
id INT NOT NULL AUTO_INCREMENT,
name VARCHAR(30) NOT NULL,
type VARCHAR(30) NOT NULL,
PRIMARY KEY(id)
);
Based on that table would this be correct for the insert in my php? (assuming "rofl" is the image directory)
mysql_query("INSERT INTO uploaded_images (image_url)VALUES('rofl/".$_FILES["image"]["name"]."')") or die(mysql_error());
All help is greatly appreciate.