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
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!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.