Jump to content

phpBB Digests: adding Polls


sbourdon

Recommended Posts

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!

Link to comment
https://forums.phpfreaks.com/topic/58827-phpbb-digests-adding-polls/
Share on other sites

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!

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.