I noticed that Message-ID: <Km**********************@news.easynews.com>
from Neal contained the following:
yes.....something like that. My results are stored in MySQL database
with fields qone, qtwo, qthree, etc...
Each question has 6 possible answers / values ranging from Excellent to
Unsatisfactory. Can I see your source code?
Because this is designed to be re-used for all sorts of different votes,
I store the choices as a comma separated list in the ballot table, but
of course there is only one question. Anyway, if it helps, see below
for the relevant bit of code. Looking through it, I think the html is a
little screwed, but it works and the only thing the validator picks up
is missing alt attributes on the .gifs used for the bars..
....
$ballotid=$_GET['ballotid'];
$db = @mysql_connect("server", "user", "password")or
die("Could not connect: " . mysql_error());;
mysql_select_db("database_name",$db);
$sql="SELECT * from ballot WHERE ballotid='$ballotid' AND
end_date>now()";
$result = mysql_query($sql);
$vote_finished = mysql_num_rows($result);
$sql="SELECT * from ballot,vote,voter WHERE ballot.ballotid='$ballotid'
AND ballot.ballotid=vote.ballotid and voter.voterid=vote.voterid AND
vote.confirmed='Yes'AND (status is null OR status='OK')";
$result = mysql_query($sql);
$totalrows = mysql_num_rows($result);
$myrow = mysql_fetch_array($result);
?>
<body bgcolor="#FFFFFF" text="#000000">
<h1 align="center">GB Voting </h1>
<h2 align="center">Welcome to the results page</h2>
<h2 align="center">The issue in question is:</h2>
<h1 align="center"><?php print $myrow['description']; ?></h1>
if($vote_finished>0){
print"<h3 align=\"center\"><a href=\"vote.php?$ballotid\">Vote still
running</a></h3>";
$result = mysql_query("SELECT UNIX_TIMESTAMP(end_date) AS unixdate FROM
ballot WHERE ballotid='$_GET[ballotid]'" ,$db);
$myrow = mysql_fetch_array($result);
$RealDate = date("F jS, Y", $myrow["unixdate"]);
print "<h1 align=\"center\" class=\red\">Results available on
$RealDate</h1></body></html>";
exit;
}
?>
<h3 align="center">Only confirmed votes (<?php print $totalrows; ?>) are
counted</h3>
<?php
//summary
$choices= explode(",", $myrow['choices']);
if($totalrows>0){
print"<hr size=\"1\" width=\"90%\"><table width=\"75%\" border=\"0\"
cellspacing=\"0\" cellpadding=\"3\" align=\"center\">";
for ($i=1;$i<count($choices); $i++){
$picked=trim(addslashes($choices[$i]));
$sql="SELECT * from vote WHERE choice='$picked' AND confirmed='Yes' AND
ballotid='$_GET[ballotid]'AND (status is null OR status='OK')";
$result = mysql_query($sql);
$numrows=mysql_numrows($result);
$percent=number_format(($numrows*100/$totalrows),1);
print "<tr>
<td width=\"39%\"align=\"right\"><b>$choices[$i]</b></td>
<td width=\"21%\"> = <b>$numrows</b> ($percent%)</td>
<td width=\"40%\"><table width=\"100%\" border=\"0\"
cellspacing=\"0\" cellpadding=\"0\">
<tr>
<td class=\"border\"><img src=\"redline.gif\" width=\"$percent%\"
height=\"3\"></td>
</tr>
</table></td>
</tr>";
}
print "</table>";
//end summary
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs
http://www.ckdog.co.uk/rfdmaker/