Jump to content


Photo

Biiiig Poll


  • Please log in to reply
1 reply to this topic

#1 Dragoonus

Dragoonus
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 28 February 2005 - 11:52 PM

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

#2 Dragoonus

Dragoonus
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 01 March 2005 - 11:45 PM

I started from scratch and have now managed it, as I found no delete option I thought I'd better tell you :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users