About
|
|
Author: FR
|
|
Credits:
|
|
|
Brookfresh, Brad Lawryk, Crogon, DaMysterious, EklipzeDesigns, ML, musashi, phpBB Group, phpBB-Auction-Team, php-styles, sanman, Tel, Vampy, wGEric
|
|
Supported Sites
|
|
Statistics
|
User:
|
18793
|
Posts:
|
18401
|
Latest User:
|
lonnygixer
|
|
|
|
View previous topic :: View next topic |
Author |
Message |
Dude Small-Cap Auctioneer

Joined: 12 Mar 2005 Posts: 1
|
Posted: Sat Mar 12, 2005 5:35 pm Post subject: Polls |
|
|
Hey FR, I've been trying for a while now too add pagination to your polls page, it almost works but I'm needing some help Code: | <?php
//////////////////////////////
// poll.php
// -------------------
// begin : July 2004
// copyright : (C) FR
// email : fr@php-styles.com
//////////////////////////////
define('IN_PHPBB', true);
$phpbb_root_path = './';
include_once($phpbb_root_path . 'extension.inc');
include_once($phpbb_root_path . 'common.'.$phpEx);
include_once($phpbb_root_path . 'includes/bbcode.'.$phpEx);
// Start session management
$userdata = session_pagestart($user_ip, PAGE_POLLS);
init_userprefs($userdata);
// End session management
// Output page header
$page_title = $lang['poll_overview'];
include_once($phpbb_root_path . 'includes/page_header.'.$phpEx);
$template->set_filenames(array('body' => 'polls.tpl'));
$start = ( isset($HTTP_GET_VARS['start']) ) ? intval($HTTP_GET_VARS['start']) : 0;
if(isset($HTTP_POST_VARS['order'])){
$sort_order = ($HTTP_POST_VARS['order'] == 'ASC') ? 'ASC' : 'DESC';
}
else if(isset($HTTP_GET_VARS['order'])){
$sort_order = ($HTTP_GET_VARS['order'] == 'ASC') ? 'ASC' : 'DESC';
}
else{
$sort_order = 'ASC';
}
$select_sort_order = '<select name="order">';
if($sort_order == 'ASC'){
$select_sort_order .= '<option value="ASC" selected="selected">' . $lang['Sort_Ascending'] . '</option><option value="DESC">' . $lang['Sort_Descending'] . '</option>';
}
else{
$select_sort_order .= '<option value="ASC">' . $lang['Sort_Ascending'] . '</option><option value="DESC" selected="selected">' . $lang['Sort_Descending'] . '</option>';
}
$select_sort_order .= '</select>';
$sql = "SELECT topic_title,
topic_id
FROM " . TOPICS_TABLE . "
WHERE topic_vote<>''
ORDER BY topic_time $sort_order
LIMIT $start, ".$board_config['topics_per_page'];
if ( !($result = $db->sql_query($sql)) ){
message_die(GENERAL_ERROR, 'Could not query post with polls', '', __LINE__, __FILE__, $sql);
}
$total_post_polls = 0;
while( $row = $db->sql_fetchrow($result) ){
$post_poll_rowset[] = $row;
$total_post_polls++;
} // while
for($j = 0; $j < $total_post_polls; $j++){
$sql = "SELECT vd.vote_id,
vd.vote_text,
vd.vote_start,
vd.vote_length,
vr.vote_option_id,
vr.vote_option_text,
vr.vote_result
FROM " . VOTE_DESC_TABLE . " vd, " . VOTE_RESULTS_TABLE . " vr
WHERE vd.topic_id = " . $post_poll_rowset[$j]['topic_id'] . " AND
vr.vote_id = vd.vote_id
ORDER BY vr.vote_option_id ASC";
if ( !($result = $db->sql_query($sql)) ){
message_die(GENERAL_ERROR, "Could not obtain vote data for this topic", '', __LINE__, __FILE__, $sql);
}
if ( $vote_info = $db->sql_fetchrowset($result) ){
$db->sql_freeresult($result);
$vote_options = count($vote_info);
$vote_id = $vote_info[0]['vote_id'];
$vote_title = $vote_info[0]['vote_text'];
$view_result = 0;
$vote_results_sum = 0;
for($i = 0; $i < $vote_options; $i++){
$vote_results_sum += $vote_info[$i]['vote_result'];
}
$vote_graphic = 0;
$vote_graphic_max = count($images['voting_graphic']);
$u_topic = $post_poll_rowset[$j]['topic_id'];
$template->assign_block_vars('post_poll',array(
'POLL_QUESTION' => $vote_title,
'L_TOTAL_VOTES' => $lang['Total_votes'],
'TOTAL_VOTES' => $vote_results_sum,
'S_HIDDEN_FIELDS' => $s_hidden_fields,
'TOPIC_TITLE' => $post_poll_rowset[$j]['topic_title'],
'U_TOPIC'=> append_sid($u_topic) ));
for($i = 0; $i < $vote_options; $i++){
$vote_percent = ( $vote_results_sum > 0 ) ? $vote_info[$i]['vote_result'] / $vote_results_sum : 0;
$vote_graphic_length = round($vote_percent * $board_config['vote_graphic_length']);
$vote_graphic_img = $images['voting_graphic'][$vote_graphic];
$vote_graphic = ($vote_graphic < $vote_graphic_max - 1) ? $vote_graphic + 1 : 0;
if ( count($orig_word) ){
$vote_info[$i]['vote_option_text'] = preg_replace($orig_word, $replacement_word, $vote_info[$i]['vote_option_text']);
}
$template->assign_block_vars("post_poll.poll_option", array(
'POLL_OPTION_CAPTION' => $vote_info[$i]['vote_option_text'],
'POLL_OPTION_RESULT' => $vote_info[$i]['vote_result'],
'POLL_OPTION_PERCENT' => sprintf("%.1d%%", ($vote_percent * 100)),
'POLL_OPTION_IMG' => $vote_graphic_img,
'POLL_OPTION_IMG_WIDTH' => $vote_graphic_length));
}
}
}
$template->assign_vars(array(
'PAGINATION' => sprintf($lang['Page_of'], ( floor( $start / $board_config['topics_per_page'] ) + 1 ), ceil( $total_members / $board_config['topics_per_page'] )) . $pagination,
'S_ORDER_SELECT' => $select_sort_order,
'S_MODE_ACTION' => append_sid("polls.$phpEx"),
'L_OVERVIEW' => $lang['poll_overview']));
$template->pparse('body');
include_once($phpbb_root_path . 'includes/page_tail.'.$phpEx);
?> |
|
|
Back to top |
|
 |
FR Site Admin

Joined: 26 Jan 2004 Posts: 1764 Location: root directory
|
|
Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|