Jump to content


Photo

Inserting an Image into an existing Record?


  • Please log in to reply
3 replies to this topic

#1 mikerosenthal

mikerosenthal
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 23 October 2006 - 09:49 PM

OK. i really have been trying to do this for weeks, but keep in mind i am more or less a newbie...

I have setup an event calendar system wherein the administrator creates a new event from a calendar (well, from the php script webcalendar - http://www.k5n.us/webcalendar.php). once this event is created, she can then go to an Event Editor page i built, where she can fill out a lot more information about the event (price, description, staffing, etc). I would also like for her to be able to insert an image into this existing record while she is filling out all this other info, then hit save, and have all this info and the image saved with the record.

I have read many tutorials on how to upload and display images using php and mysql. I have gotten these to work just fine. however, none of them seem to take into account the scenerio of wanting to upload an image into an existing record (ie, they all create a new unique id), whereas i need the example to take into account the unique id of whatever record she is editing and replace into (or insert into? im confused) that one.

i realize this is a slightly confusing post, so please feel free to ask me to clarify a point or post an example. but does anyone understand my confusion? or can anyone point me to a tutorial on uploading images into existing mysql records from php?

thanks for your help!

-mike


#2 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 23 October 2006 - 10:10 PM

At the moment you probably have something like

UPDATE events SET
    description = '$description',
    price = '$price'
WHERE eventid = '$id';

Having uploaded the image and moved to "$path/$filename" on the server, your update becomes

UPDATE events SET
    description = '$description',
    price = '$price',
    image = '$path/$filename'
WHERE eventid = '$id';

If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#3 mikerosenthal

mikerosenthal
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 28 October 2006 - 08:29 PM

actually, im trying to store the images in the mysql table. does that make a difference?


#4 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 28 October 2006 - 08:54 PM

Not recomended, better to store file on server and the link to it in the db
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users