Jump to content

Need help on proper approach(Inserting data with IMG)


bugzy

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);

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.