Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Storing image links in MYSQL

Status
Not open for further replies.

kjspear

Programmer
Feb 13, 2002
173
US
Hello,

What is the simplest way to insert image links to the MYSQL database? Based on my research, it's not a good idea to save the actual BLOB images to the database but rather the link to it. What I would like to do is upload a small jpeg or gif file and have MYSQL retrieve it for viewing. The user may also click a next button to scroll to the next image. Most of the samples I've seen appear to be complicated. I just want something as simple as possible.

Any assistance would be gladly appreciated.

Thanks,
KJ
 
Your table might look something like:

create table foo
(
ID int unsigned auto_increment primary key,
imagefilename varchard (30)
)

You store your image data in that table.

You then write a script (call it "foo.php")that can take an optional input of a table ID value.

If foo.php does not get an ID when it is run, it fetches the first filename in the table, wraps HTML tags around it, then outputs that. It also fetches the ID of the next image in the table and output that as a link (something like <a href=&quot;foo.php?id=<idval>&quot;...>).

If it gets an ID, it does everything it did in the paragraph above, but also gets the ID of the previous image in the table and outputs that as an A tag.

Want the best answers? Ask the best questions: TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top