Jump to content


Images in a Blog

  • Please log in to reply
2 replies to this topic

#1 Konnor

  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 08 August 2006 - 10:49 PM

I'm super new to blogging/php/mySQL and in the process of coding my own (following a tutorial from the book 'blog design solutions').

Unfortunately it doesnt show you how to add images to a blog post. Presumably you cannot directly store the image in the database, only a link to it.

Ideally I would like a setup where I may or may not have an image for each blog post. What would I put as the field in the table? How could I code it so I sometime have images in my blog post and sometimes don't?

My table currently looks like this..

Posted Image

And my addpost screen looks like this

Posted Image

#2 nethnet

  • Members
  • PipPipPip
  • Advanced Member
  • 284 posts
  • LocationPhiladelphia, PA, USA

Posted 08 August 2006 - 10:59 PM

Actually, you can store images in a MySQL database if you create the field as a BLOB type.
"Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep."  --Scott Adams

Current project: nethnet.com

#3 corbin

  • Staff Alumni
  • Advanced Member
  • 8,129 posts

Posted 08 August 2006 - 10:59 PM

add a column to your table that is something like pic_url then
You could add a picture url box on your form so they could put one if they wanted...

Then when the form is processed have it put the url in the database if its a valid url...

then when displaying it if the url column doesnt equal "" you could display it in an image tag
Why doesn't anyone ever say hi, hey, or whad up world?

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users