Jump to content

Biiiig Poll


Recommended Posts

I have made polls in the past no problem, perhaps I forgot how, I dunno, anyhoos I recently decided to make a large poll (and simply call it vote) however after making the options into a select list I have encountered nothing but problems, after solving god knows how many I have ended up with the following code (messy I know...

<?php require_once('Connections/myplace.php'); ?>
<?php
mysql_select_db($database_myplace, $myplace);
$query_Vote = "SELECT title FROM links_link";
$Vote = mysql_query($query_Vote, $myplace) or die(mysql_error());
$row_Vote = mysql_fetch_assoc($Vote);
$totalRows_Vote = mysql_num_rows($Vote);
?>
<?php echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?".">"; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<?php
mysql_select_db($database_myplace, $myplace) or die("Couldn't open $db: ".mysql_error());
foreach ($check as $value){
mysql_query("UPDATE links_link SET Vote=Vote+1 WHERE voter =title");
}
$result = mysql_query( "SELECT title,Vote FROM links_link" ) or die("SELECT Error: ".mysql_error());
//display the updated results
$num_rows = mysql_num_rows($result);
print "<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";
print "<table ID=poll cellspacing=0 cellpadding=5 width=125 >\n";
print "<tr valign=top><td colspan=2 bgcolor=#004f9d><h3>Other users chose these options.</h3></td></tr>\n";
while ($get_info = mysql_fetch_row($result)){ 
print "<tr>\n";
foreach ($get_info as $field ) 
print "\t<td>$field</td>\n";
print "</tr>\n";
}
print "</table>
</tr></table></body></html>\n";
mysql_close($link);
?> 
<table ID="poll" width="125" cellpadding="2" cellspacing="0" border="0">
<tr align="center" valign="top">
<td align="left" colspan="1" rowspan="1">
<h4>Arrrrrgggg!!!</h4>
     <form action="yh.php" method="GET" name="formvote" id="formvote">
       <select name="voter" size="15">
         <?php
do {  
?>
         <option value="<?php echo $row_Vote['title']?>"<?php if (!(strcmp($row_Vote['title'], $row_Vote['title']))) {echo "SELECTED";} ?>><?php echo $row_Vote['title']?></option>
         <?php
} while ($row_Vote = mysql_fetch_assoc($Vote));
 $rows = mysql_num_rows($Vote);
 if($rows > 0) {
     mysql_data_seek($Vote, 0);
  $row_Vote = mysql_fetch_assoc($Vote);
 }
?>
       </select>
<input type="submit" value="Results"><input type="reset">
</form>
</td></tr></table> 

</body>
</html>
<?php
mysql_free_result($Vote);
?>



 

Everything seems to work, I can choose my options, view the results however once I submit it doesn't update the database... (I even tried onsubmit= blah... blah.. yet no joy)

 

I think it might be something to do with the

mysql_query("UPDATE links_link SET Vote=Vote+1 WHERE voter =title");

part perhaps?

 

The code is not mine, i have just edited it, perhaps this is one of the reasons... none the less I'm unsure as to why it won't update the field, its probalby something really simple, but meh I'm new to this (I'm sure you get many of my type lol)

 

Thanks in advance

 

- Confused PHP/MySQL Newb Dragoonus

Link to comment
https://forums.phpfreaks.com/topic/2181-biiiig-poll/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.