11-30-2007, 09:53 PM
|
#6 (permalink)
|
|
The Acquainted
Join Date: Sep 2007
Location: Leeds, UK
Posts: 141
Thanks: 6
|
Hey trmbne2000, thanks for the response, it's helped a bit.
Could I show you my function I've wrote? Perhaps someone may want to work off that? I'm not asking "Hey, do this for me" because that's the last thing I care for, as how else am I to learn, but, in this case, I've had an hectic two weeks in trying to find a job, and I always seem to have plans, so... if anyone could use my code and let me know what I could do to get the results I want, I'd appreciate it a lot!
PHP Code:
//-------------------- // Poll //-------------------- function poll() { // Query $queryPoll = mysql_query(sprintf(" SELECT poll_id, question, who_voted FROM poll WHERE creator_id = '%d'", getIdByUsername($_GET['uid']) )) or die(mysql_error()); // Display content if($q = mysql_fetch_array($queryPoll)) { $output = ' <form action="" method="post"> <div class="sub-header">'.$q['question'].'</div> <div class="content-box"> '; // Query for the options $queryOptions = mysql_query(sprintf(" SELECT poll_options_id, choice FROM poll_options WHERE from_poll_id = '%d'", $q['poll_id'] )) or die(mysql_error()); $voted = unserialize($q['who_voted']);
// Loop over options while($o = mysql_fetch_array($queryOptions)) { if(@in_array($_COOKIE['userID'], $voted)) { $queryVotes = mysql_query(sprintf(" SELECT COUNT(vote_id) AS total FROM poll_vote WHERE option_id = '%d'", $o['poll_options_id'] )) or die(mysql_error()); // Fetch $v = mysql_fetch_array($queryVotes); $output .= ' <div class="poll-option"> '.$o['choice']. ' - ' .$v['total'].' - ' . round(100 * $v['total'] / 3, 2) .' </div> '; } else { $output .= ' <div class="poll-option"> <input name="poll_choice" type="radio" value="'.$o['poll_options_id'].'" /> '.$o['choice'].' </div> '; } } $output .= ' </div> <div align="center"> '; if(!@in_array($_COOKIE['userID'], $voted)) { $output .= ' <input type="submit" value="Vote!" /> '; } $output .= ' </div> </form> '; } echo $output; }
Thanks, really!
Off topic: I got the PM about the "award" not sure if I was given this personally by Wildhoney, or if you get it after the post count reaches the limit... either way, thanks!
__________________
Not quite a n00b...
|
|
|
|