Code: Select all
$sql = 'SELECT *
FROM ' . POLL_OPTIONS_TABLE . "
WHERE topic_id = " . (int) $topic_id;
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
$sql2 = 'SELECT *
FROM ' . POLL_VOTES_TABLE . "
WHERE poll_option_id = " . $row['poll_option_id'] . "
AND topic_id = " . $topic_id;
$result2 = $db->sql_query($sql2);
$voted_users = '';
while ($row2 = $db->sql_fetchrow($result2))
{
$sql3 = 'SELECT user_id, username, user_colour
FROM ' . USERS_TABLE . "
WHERE user_id = " . $row2['vote_user_id'];
$result3 = $db->sql_query($sql3);
$row3 = $db->sql_fetchrow($result3);
$voted_users .= get_username_string('full', $row3['user_id'], $row3['username'], $row3['user_colour']) . ' (' . $row2['vote_user_ip'] . ') ';
$db->sql_freeresult($result3);
}
$db->sql_freeresult($result2);