PHP Poll<

liunx

Guest
I am looking to write my own php poll script, only problem is im new to this language and have no idea where to start

can anyone give me any help or point me in the direction of some tutorials to creating my own poll

i would preferably like to write my own as ones to Download from the net have credits and things on them and i dont want these

any help would be appreciated,

Joehmm, well. Think out how you want the poll data stored, in a database or a flat file. I have never used a database, if I was to make one I'd make the data file structure about similiar to the following...
Poll id|Poll question|voting options|voting data|IPs that have voted
One poll per line, the one on bottom (or the top if you prefer) is the newest, you edit them in a simple admin feature that you also have created. So an example of a poll datafile could be:
3|What's your favorite fruit?|banana;orange;other|4,7,2|233.5.63.75,145.0.7.5
2|What's your favorite serverside language?|perl;php;asp;other|300000,0,0,0|5.62.194.52
1|Do you like this site?|yes;no;dunno|43,12,8|ips here
the one at top is the newest. To show the poll, use a split function (I suppose PHP has one) to split the different sections separated by |, then in section 0 is the id, 1 is the question, in section 2 split the options, separated by semicolons, in section 3 split the number of votes for each option, separated by commas, in section 4 save all voters' IPs to prevent skewing.i dont really care how the data is stored, a text file or in a database is fine by me

all i want really is:

poll question

radio button: choice one
radio button: choice two
radio button: choice three
radio button: choice four
radio button: choice five

submit button
view results link

then when the user votes i want (similar to the poll feature on this forum) each choice and a coloured bar and a percentage showing each choicefor the coloured bars, make a 1px wide image for the bar, for instance a 14x1 blue GIF. Then, in your PHP, calculate the percentage of votes for the option (votes / total votes * 100), and round the eventual decimal off. If it got, let's say 59% of the votes, then you show the blue bar image stretched to 59px (or the double, 118px).yes, but the problem is im new to PHP and i dont have a clue how to do that, which is why i will need help from scratch with this oneHi joe, you could probably find some tutorials on fwrite() if you want to use a flat file, or writing to a database at these sites:
<!-- w --><a class="postlink" href="http://www.snippetlibrary.com">www.snippetlibrary.com</a><!-- w -->
<!-- w --><a class="postlink" href="http://www.devshed.com">www.devshed.com</a><!-- w -->
<!-- w --><a class="postlink" href="http://www.phpfreaks.comthanks">www.phpfreaks.comthanks</a><!-- w --> Josh, i will check them out

i've been on snippetlibrary and didnt really find anything but i will try the othersI've found that the tutorials on php freaks are very helpful. And they have a ton.well creating the poll is easy. have a html form and have all of the info you need,

a title, question boxes, maybe something to refer to it (a short name so to speak)

then save that info to the db. don't do flat files as it is a tedious job.

then on the page you have a query to get the info (title and question) and present it in a resaonable fashion, that is easy. the hard part is showing the results.

I have a tutorial on how to query the database, tha tcan be used to insert as well.

once you get that far and it is showing on the page we can do the hard part.would i be completely stupid in assuming that this is already a hard part :confused:

but i will try

Poll Question

Radio Button - Option 1
Radio Button - Option 2
Radio Button - Option 3
Radio Button - Option 4
Radio Button - Option 5
Submit Button
Results link

i would need to store the users IP so they can only vote once and i would need to store what they clicked

this is about as much as i know, i dont know anything about turning this into querys and things :confused:

complete n00bthat is why you need to read

<!-- m --><a class="postlink" href="http://www.snippetlibrary.com/tutorials/tutorials.php/2/11/159">http://www.snippetlibrary.com/tutorials ... p/2/11/159</a><!-- m -->

as it will teach you how to do a simple query.

but do the html part first tehn we can go from there.Good tutorial scoutt, it helped me :)
 
Back
Top