SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Zealot impunjabians's Avatar
    Join Date
    Dec 2007
    Location
    Bed Room
    Posts
    134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    help on Photo table

    i am working on a website for car's inventory and customer requirement is to store 30 images for on car, i created sperated table for images and then 30 fields sperately to store the path of every image, is it best way to do this or is there else? how can i reduce the no fields to store all 30 image's paths

    Regards,

    Faxi

  2. #2
    SitePoint Wizard holmescreek's Avatar
    Join Date
    Mar 2001
    Location
    Northwest Florida
    Posts
    1,707
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, first you can write a back-end cms that has file input fields to let you select the images from your computer to upload. Next, store all the images in the same folder on your server...this way, in your database you only have to store the filename and not the full path+filename.

    Finally, you could store the product_id, car_title, car_details in a mysql table called cars with a key field called cars_id. Next, you can create a table called car_photos like so...

    id | car_photo | cars_idx


    cars_id would be equal to cars_idx


    This would take care of the issue if less than 30 photos or more than 30 photos where associated with a particular car. example :

    TABLE "cars"
    cars_id | cars_name | cars_desc

    1 1990 Jaguar Nice Jaguar
    9 2006 Datsun Sardine Can

    TABLE "car_photos"
    id | car_photo | cars_idx

    1 jaguar_01.jpg 1
    2 jaguar_02.jpg 1
    3 jaguar_03.jpg 1
    ...

    31 datsun_01.jpg 9
    32 datsun_02.jpg 9

    ...

    then a query like so :

    select car_photo from cars,car_photos where cars_id=cars_idx


    hope this gives you some alternative ideas
    intragenesis, llc professional web & graphic design


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
  •