homepage Welcome to WebmasterWorld Guest from 50.17.107.233
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Newbie needs help with polling app
stephen675




msg:3815821
 8:57 pm on Dec 29, 2008 (gmt 0)

Hi Guys,

I've been working with MySQL and PHP for the last 2 weeks (yep, two whole weeks of experience) and I'm stuck trying to figure out what script to leverage to build a custom polling app. Most of the scripts I have seen so far generally have stuff I don't want or isn't sufficient for my needs and maybe I'm saying this because I don't know how to leverage what's available out there (e.g., ability to setup multiple polls, polls only asking one question, IP based authentication to prevent multiple votes, ability for users to create polls, etc. are things I don't need): Following are my requirements:

High Priority:
1) I need *only* one poll with 10 questions (this can be hardcoded if that helps)
2) Each question will have 3-5 answers
3) Answers will be in selected using radio buttons
4) Use MySQL to store answers

Medium Priority:
1) Use vBulletin's 'member' profile to authenticate users (I'm pretty sure I can do this myself)

Low Priority:
1) Ability for members to update their votes if they so choose (this would be a nice to have)

So far, my table looks like the following:
a) Id (primary key)
b) vbulletin_userid
c) vote_date
d) Q1_answer_1
e) Q1_answer_2
f) Q1_answer_3
g) Q2_answer_1
h) Q2_answer_2
i) Q3_answer_1
...

Most of the stuff out there seems to have one table for question and another for answers so my requirements are simpler in some ways but all of the scripts I've seen so far don't show how to do multiple questions per poll.

Also, if someone is kind enough to direct me on how to do this, I would really appreciate it. I'm a pretty fast learner (I think...) and would certainly appreciate the help.

Thanks,

Stephen

 

The Contractor




msg:3815863
 10:11 pm on Dec 29, 2008 (gmt 0)

I'm sorry I can't help you with the PHP scripting, but you have probably been looking at the wrong scripts if you have been looking at "polls/polling" scripts. Look for online survey scripts as it sounds like that's what you need.

stephen675




msg:3815891
 11:07 pm on Dec 29, 2008 (gmt 0)

You're right, I haven't searched for survey scripts. I'll do that as well.

Thanks for the suggestion,

Stephen

stephen675




msg:3815913
 11:48 pm on Dec 29, 2008 (gmt 0)

Ok, found my answer. Thanks again for the suggestion.

Now the next question - is there a way to submit multiple updates in one query. Currently, I'm planning to do something like the following:

mysql_query("INSERT tbl_survey SET q1_answer_1=1, userid='$userid', item='$item' WHERE area='$q1_answer_1');

mysql_query("UPDATE tbl_survey SET q1_answer_2=1 WHERE userid='$userid' AND item='$item' AND area='$q1_answer_2');

mysql_query("UPDATE tbl_survey SET q1_answer_3=1 WHERE userid='$userid' AND item='$item' AND area='$q1_answer_3');

...

As you can see, the first query inserts the info and the following queries update the first insert. Obviously this can become quite cumbersome with 45 answers... Is there a simpler way of setting these into an array and executing one insert row all at once WHERE item='$item_nbr' and userid='$userid' ? Any help is appreciated.

Thanks,

Stephen

stephen675




msg:3815997
 2:46 am on Dec 30, 2008 (gmt 0)

Ok, ignore the code in the last post... it should be something like this... :)

mysql_query("INSERT tbl_survey SET q1_answer_1=1, userid='$userid', item='$item'');

mysql_query("UPDATE tbl_survey SET q1_answer_2=1 WHERE userid='$userid' AND item='$item');

mysql_query("UPDATE tbl_survey SET q1_answer_3=1 WHERE userid='$userid' AND item='$item');

...

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved