im new to php and i need help with polls
Moderator: General Moderators
-
gaogier
- Forum Contributor
- Posts: 391
- Joined: Wed Mar 02, 2005 1:02 pm
- Location: Portsmouth, UK
- Contact:
im new to php and i need help with polls
can someone help me to make a working poll that will go with my site http://runehints.com
what is it with runescape...?
Anyway, it depends on whether you want to use MySQL. If so, create a table and have it update when the form is submitted. Otherwise, you can just use a text file, where the data could be stored as:
##|##|##|##|##|##
where ## is the number of votes.
pretty sure I got that right...
Anyway, it depends on whether you want to use MySQL. If so, create a table and have it update when the form is submitted. Otherwise, you can just use a text file, where the data could be stored as:
##|##|##|##|##|##
where ## is the number of votes.
Code: Select all
$data = file_get_contents('name.poll');
$data = explode("|",$data);
$data[$_POST['vote']]++;
$data = implode("|",$data);
$file = fopen('name.poll','w');
fwrite($file,$data);
fclose($file);-
gaogier
- Forum Contributor
- Posts: 391
- Joined: Wed Mar 02, 2005 1:02 pm
- Location: Portsmouth, UK
- Contact:
http://www.runehints.com/poll.php
go there and thats what i get
i used one from somehting on google search
heres what i got
and the form tables
go there and thats what i get
i used one from somehting on google search
heres what i got
Code: Select all
<?php
$db="e;mydatabase"e;;
$link = mysql_connect("e;localhost"e;);
if (! $link) die("e;Couldn't connect to MySQL"e;);
mysql_select_db($db , $link) or die("e;Couldn't open $db: "e;.mysql_error());
Contents
Free PHP MySQL Tools
Introduction to PHP MySQL
Connecting to the Server
Creating a Database
Create a Table
Adding Data
Displaying Data
Editing Table Data
Altering Tables
Advanced
Multiple Selection Forms
/*loop through the selected fields - multiple if using checkbox*/
foreach ($check as $value){
mysql_query("e;UPDATE simplepoll SET number=number+1 WHERE code LIKE '$value'"e;);
}
//select the new updated values
$result = mysql_query( "e;SELECT color,number FROM simplepoll"e; ) or die("e;SELECT Error: "e;.mysql_error());
//display the updated results
$num_rows = mysql_num_rows($result);
print "e;<html><head><style type=text/css>
#poll{border-top :solid #004f9d 2px;border-left :solid #004f9d 2px} #poll tr td {border-bottom :solid #004f9d 2px;border-right :solid #004f9d 2px} #poll tr td {font-family: Small Fonts;font-style : normal ;font-size : 7pt; font-weight :bold } h3{font-family: Arial;font-style : normal ;font-size : 9pt; font-weight :bold;text-align : center; color :#FFFFFF;background-color :#004f9d }</style>
</head>
<body>
<table width=100%><tr valign=top><td>\n"e;;
print "e;<table ID=poll cellspacing=0 cellpadding=5 width=125 >\n"e;;
print "e;<tr valign=top><td colspan=2 bgcolor=#004f9d><h3>Other users chose these options.</h3></td></tr>\n"e;;
while ($get_info = mysql_fetch_row($result)){
print "e;<tr>\n"e;;
foreach ($get_info as $field )
print "e;\t<td>$field</td>\n"e;;
print "e;</tr>\n"e;;
}
print "e;</table>
</tr></table></body></html>\n"e;;
mysql_close($link);
?>and the form tables
Code: Select all
<dt><input type="e;checkbox"e; name="e;checkї]"e; value="e;c1"e;>
Place style sheets in head section:
#poll{ ;border-style : solid ;border-color : #004f9d ;border-width : 2px}
#poll tr td dt{font-family: Small Fonts;font-style : normal ;font-size : 7pt; font-weight :bold }
<table ID="e;poll"e; width="e;125"e; cellpadding="e;2"e; cellspacing="e;0"e; border="e;0"e;>
<tr align="e;center"e; valign="e;top"e;>
<td align="e;left"e; colspan="e;1"e; rowspan="e;1"e;>
<h4>Select your favorite color.</h4>
<form method="e;POST"e; action="e;simple-poll.php"e;>
<dl>
<dt><input type="e;radio"e; name="e;checkї]"e; value="e;c1"e;>Red<br>
<dt><input type="e;radio"e; name="e;checkї]"e; value="e;c2"e;>Green<br>
<dt><input type="e;radio"e; name="e;checkї]"e; value="e;c3"e;>Blue<br>
<dt><input type="e;radio"e; name="e;checkї]"e; value="e;c4"e;>Yellow<br>
</dl>
<input type="e;submit"e; value="e;Results"e;><input type="e;reset"e;>
</form>
</td></tr></table>i'm missing something here.
What you want is that when some one clicks on one of the images at the bottom of the page in the desclaimer section you want that to register as a vote for the site?
Or do you want a seperate list that people will choose from.
Is the db holding the votes being hosted by you or is it going to be by someone else?
What you want is that when some one clicks on one of the images at the bottom of the page in the desclaimer section you want that to register as a vote for the site?
Or do you want a seperate list that people will choose from.
Is the db holding the votes being hosted by you or is it going to be by someone else?
the one you showed simple-poll.php will do the job but it doesn't look that good to me.
http://www.hotscripts.com/PHP/Scripts_a ... nd_Voting/
has some more to try and have readme.txt files with them to help you install them.
Some are even free.
try those out to see if any work for you.
if not it wouldn't be to hard to create your own if that is what you wished, depending on the options that you want.
http://www.hotscripts.com/PHP/Scripts_a ... nd_Voting/
has some more to try and have readme.txt files with them to help you install them.
Some are even free.
try those out to see if any work for you.
if not it wouldn't be to hard to create your own if that is what you wished, depending on the options that you want.
try easypoll
its not very advanced but it might serve the purpose and you can easily modify the look and feel of questionaire, its just simple html and some special tags. read the readme.html that comes with it.
sounds simple enough to me.
One drawback that jumped out at me was the limit of five questions but im sure that could be overcome.
http://www.phpwebscripts.com/free_scrip ... _poll.html
its not very advanced but it might serve the purpose and you can easily modify the look and feel of questionaire, its just simple html and some special tags. read the readme.html that comes with it.
sounds simple enough to me.
One drawback that jumped out at me was the limit of five questions but im sure that could be overcome.
http://www.phpwebscripts.com/free_scrip ... _poll.html
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact: