close ad
Install the LAtest Updates to Work with CC 2017 and CC 2018
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Photo Contest voting lookup

Thread began 2/16/2010 11:42 am by robert329616 | Last modified 2/17/2010 12:33 am by CraigR | 696 views | 5 replies |

robert329616

Photo Contest voting lookup

Hello,

I have been struggling with this part of the site.

I have a voting site (www.dogpediccontest.com) where people after registering can upload their pets picture and vote for their pet. I was able to get this to work.

I need help with the voting end. I have it set up where the person (friends, family, etc) registers then is taken to a protected page (registrants by email only). Here I need to allow them to see all the photos and names and a button to allow them to vote. They can only vote once per email address, so once they vote they would not be able to see this page.

I have one table (I was out of time so i am only using this now):
users: UserID, UserEmail, UserPassword, UserFirstName, UserLastName, PetName, PetImage, ContestTerms, PetVotes, UserEmailVerified, UserRegistrationDate, UserVerificationCode, UserIP, UserPhone

and votes: VoteID, VoteUserID, PetVotes, petName, VoteDate

My question is; Are the tables set up right? What is the correct SQL statement to allow me to show all the pet names, pictures and allow the registered user to vote?

The site had to go live and I am beyond having a gun to my head, so any help would be greatly appreciated.

Thanks,
Rob

Thanks,
Rob

Sign in to reply to this post

CraigRBeta Tester

how about this...

having read your post a couple of times, i think i see what you are after

if so, i think you would be best served by 3 tables...

tbluser
tblimage
tblvote

tblvote needs to have
voteid as pk
imageid (foreign key to imageid in tblimage)
userid (foreign key to userid in tbluser)

tblimage should have all image info required
tbluser should have all user info required

your voting page would show all images from tblimage.
when the image is chosen, update tblvote with imageid selected and userid currently viewing

Sign in to reply to this post

robert329616

Craig thanks! Would I then use an inner join to show the pet image, name, and vote check box on the page that the viewer uses to vote

Rob

Sign in to reply to this post

CraigRBeta Tester

i hope i am understanding your objectives correctly, (it's late in the UK)

assuming you are in the 'protected page', you know the userid of the person logged in

on my voting form, i would have a recordset showing the images from tblimages, it doesn't need to be joined to anything, just show all of the pictures.

by selecting a picture, you would then know it's imageid.

posting the form would insert a row into tblvote adding userid and imageid, so you know who has voted and which image they have voted for

Sign in to reply to this post

robert329616

I will give it a try. I do not have a lot of sql experience, how do I set up a foreign key?

Rob

Sign in to reply to this post

CraigRBeta Tester

don't worry about the foreign key too much.

for example this means that a value for imageid in the voting table should match an imageid value in the image table.

in this way, if you need to produce a recordset to show all pictures, with number of votes for each, you would start by creating a query with an inner join on this field.

also, a value for userid in the voting table should match a userid value in the user table.
by creating a query with an inner join on this field, you could determine, for example, which user voted for which picture.

heres a quick walkthrough as i see it, (I assume you have dataassist, it's not essential , but makes things easier)

On your voting page, add a recordset to show all of the images, (select * from tblimages will do for starters)
add a dataassist repeating table with one image displayed in each 'cell' (<td> </td> tag)
also, within each cell add...
a form with a vote button
a hidden field with imageid as its data source

when you load your page, you should now see all of your images, with a vote button displayed under each image
your page now has a set of repeating forms, one for each image

now add the dataassist insert record server behavior, so that when the vote button is pressed, the imageid from the form's hidden field, along with your userid value, is inserted into tblvote.
if you wish, redirect to a 'thanks for voting page'.

that should sort it.


Hope this doesn't give you too much of a headache. ps sorry, but i probably won't be online again until the weekend.

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...