Jump to content

Recommended Posts

Hello this is my very 1st time to insert a data with an image coordinated with it...

 

I have like this tables and their columns

 

 

Category Table

 

category id(PK)

category name

 

 

Item Table

 

item_id(PK)

item_category(FK)

item_name

item_sale(bool)

item_registered

 

 

If I'm going to add an item with coordinated image, I don't know how will I put the image.

 

is it everytime I'm going to add a category, is it supposed to generate a folder? for let's say category "laptop" so all items's images with a category laptop will be put on that folder laptop?

 

in that case will category id will be the foreign key?

 

 

I hope someone will teach or explain me the proper way to do this...

 

 

Thanks!

Here is how I would do it (pseudo code):

 

$imageFilename = sprintf('%s_%s.%s', $realImageName, $guid, $extension);
SaveImage($tmpFileName, $imageFilename); // save to /images/myimage_GUID.jpg for example
$sql = "INSERT INTO Item SET ..., item_image = {$db->Quote($imageFilename)}, ...";
$db->Execute($sql);

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.