im new to php and i need help with polls
Posted: Fri May 13, 2005 11:16 am
can someone help me to make a working poll that will go with my site http://runehints.com
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
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);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);
?>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>Jcart wrote:What are you asking here? For some one to make a poll for you? --or-- are you actually going to take the time and understand how most polls and done and create your own?