Jump to content

Can this been DONE


stanleybb

Recommended Posts

Hi,

 

There's plenty of rating scripts out there.

 

have a look at google,

 

some are really compicated, some not (but are not very good either)

 

(I'm also stuggling with rating scripts at the moment, so i know where you're coming from)

 

Basically when a rating is displayed on a page, it's tied to an ID,

 

So in your case (if you don't store your pictures with an ID) it would be the name of the pic or whatever unique identifier you're using to pull them onto the page in the 1st palce

 

i kind of know how they'll work, but i can't do it either!!!

Link to comment
Share on other sites

The pictures are being uploaded onto the server and not a SQL table. Uploading to a table is even harder lol so if they have a primary key for example, you could then rate the items and link them to the ID. You then have to work out how to dispaly the rate system and make sure it works with the pictures

 

Link to comment
Share on other sites

I agree with alexhoward that creating a unique ID is the best way - and using mysql's auto_increment feature, or the equivalent in PHP is probably the safest way.  Once you create that unique ID, you can use it to create the file name. 

Link to comment
Share on other sites

The pictures are being uploaded onto the server and not a SQL table. Uploading to a table is even harder lol so if they have a primary key for example, you could then rate the items and link them to the ID. You then have to work out how to dispaly the rate system and make sure it works with the pictures

 

 

I save my images in a directory on the server, but have the file path and a unique ID for each image stored in the database.  That way, I reference all my images through the database table where the file paths are stored.  I'm guessing you would create a separate table for the rating system, but link it to the table that stores the file path and image id by using the image id as a foreign key in the rating table...

Link to comment
Share on other sites

The pictures are being uploaded onto the server and not a SQL table. Uploading to a table is even harder lol so if they have a primary key for example, you could then rate the items and link them to the ID. You then have to work out how to dispaly the rate system and make sure it works with the pictures

 

 

I save my images in a directory on the server, but have the file path and a unique ID for each image stored in the database.  That way, I reference all my images through the database table where the file paths are stored.  I'm guessing you would create a separate table for the rating system, but link it to the table that stores the file path and image id by using the image id as a foreign key in the rating table...

 

 

How did you get it to upload and create a file path and unique ID

 

P.S thanks for everybodies help btw

Link to comment
Share on other sites

when they upload the image,

 

you'll have to set the file name as a variable

 

post the image onto your server

 

then save the link into your data base as something like

 

<img src="http://www.yoursite.co.uk/images/$variable">

 

sorry i can't work out the code from here, don't have time or the resource

 

but say the link was saved as

 

<img src="http://www.yoursite.com/images/eos.jpg">

 

when you selected the link from the table where the ID = $ID

 

it would bring back

 

<img src="http://www.everyonlinestore.co.uk/images/eos.jpg">

 

does this help at all....?

Link to comment
Share on other sites

How did you get it to upload and create a file path and unique ID

 

P.S thanks for everybodies help btw

 

You can create a table that contains the image information (author, title, location, description, copyright, etc.) and relative file path on the server (i.e. my_images/image_name.jpg).  The table will also generate unique identifiers for each image using the auto_increment attribute.  I call the unique identifier the image_id.  The image_id also becomes the image name.  So if you have an image_id of 00012, the image name would be 00012.jpg. 

 

First you would populate the table with the image information and let the table automatically generate a unique image_id.  Then you would use PHP to build a select statement to extract the newly created image_id from the table.  After that, you can use PHP's move_uploaded_file function to upload the file to the server (after validating the file) - give it the correct name and put it in the right directory, according to the file path stored in your image table.

 

For example:

 

move_uploaded_file($POST['upload_file']['tmp_name'], "your_directory/".$image_id.".jpg"); 

 

or

 

move_uploaded_file($POST['upload_file']['tmp_name'], $file_path);  // Where file path is the relative path to the file on your server.

 

Obviously, you don't have to store the relative file path to the image in your database - you can just store the actual image name (and set the file path in your HTML and PHP code).  I just find it easier when I want to display images to just have that information in my database...

Link to comment
Share on other sites

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.