sbourdon Posted July 7, 2007 Share Posted July 7, 2007 Hello, I would like to include poll details in the emails sent by phpBB Digests. FYI, this phpBB MOD grabs new postings and their content since your last visit to the Forum, and include them in an email. Therefore, I need to grad poll questions and options from the database... I thought I had it all worked out, but the code goes through the loop too many times. Sometimes, options will repeat two or three times; it looks like it all depends on the number of posts available in the Forum! Here's the code I've created: $vote_text = ''; if ($row2['topic_vote'] != 0 && ($row2['topic_first_post_id'] == $row2['post_id'])) { $sql3 = "SELECT vd.vote_text, vr.vote_option_text FROM " . VOTE_DESC_TABLE . " vd, " . VOTE_RESULTS_TABLE . " vr WHERE vd.topic_id = $row2[topic_id] AND vr.vote_id = vd.vote_id GROUP BY vd.vote_text, vr.vote_option_text ORDER BY vr.vote_option_id ASC"; if ( !($result3 = $db->sql_query($sql3))) { message_die(GENERAL_ERROR, 'Could not obtain vote data for this topic', '', __LINE__, __FILE__, $sql); } while ($row3 = $db->sql_fetchrow($result3)) { if ($html) { $vote_text = $row3['vote_text'] . '<br />'; $vote_option .= '- ' . $row3['vote_option_text'] . '<br />'; } else { $vote_text = $row3['vote_text'] . "\n"; $vote_option .= '- ' . $row3['vote_option_text'] . "\n"; } } } And here's how it appears in the emails: [ Poll ] Question - Option 1 - Option 2 - Option 1 - Option 2 Options 1 and 2 should only appear once! :-\ Does anyone see what's wrong or missing here? Thanks a lot for your help and support! Quote Link to comment Share on other sites More sharing options...
sbourdon Posted July 8, 2007 Author Share Posted July 8, 2007 I've noticed that Options from Poll1 appear in Poll2, and Options from Poll2 appear in Poll3 and so on... Example: [ Poll ] Poll 1 Question - Poll1 Option A - Poll1 Option B [ Poll ] Poll2 Question - Poll1 Option A - Poll1 Option B - Poll2 Option A - Poll2 Option B Any ideas? Thanks! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.