SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Mar 2001
    Posts
    143
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Structure for Image File upload manager

    Ok I wish to give users who have access to the Control Panel the ability to upload and manage images which would be used in the article/news items that they're adding/editing.

    The problem I'm having with the planning of such is when a user wishes to add an item to the site. I thought that it would be best to have a seperate table in the db that would store the image information added.

    tbl_items_images (not showing all fields)

    IMAGE_ID
    IMAGE_ITEM_ID (which item from tbl_items the image is for)
    IMAGE_NUMBER_PER_ITEM

    However when a user is adding an article, the article does not yet have a record entry in tbl_items. So how would I possibly manage to do this in such a way that by the time the item is added to the db, all of the images relevant to the item added would have their IMAGE_ITEM_ID referring to the correct item number.

    One way I have thought about doing this is to have an additional two fields in tbl_items_images:

    IMAGE_USER_IP
    IMAGE_DATE_ADDED

    1. When the user adds the images a record would be added to the table with all the fields having values apart from IMAGE_ITEM_ID which would have a value of 0.

    2. When the article gets added, a query is done with a WHERE clause looking for USER_IP equal to the user's IP, date added equal to today's date and IMAGE_ITEM_ID equal to 0. If a record was found, it's IMAGE_ITEM_ID would be changed to the id of the new item added.

    I'd like to know if my plan/structure is any good. Even if it is, any other suggestions for the possible structures would be much appreciated.
    Bardius

  2. #2
    SitePoint Guru asterix's Avatar
    Join Date
    Jun 2003
    Posts
    847
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, if you don't have an entry for the ITEM_ID then you have a problem. What about just creating a dummy article, and then using its ID in the image table? You can always update the Item table with completed values later.

    Your IP Idea won't work if several users are behind the same proxy, as AOL does it.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •