Exemplo n.º 1
0
<?php

/**
 * 根据投票id取投票内容;
 * */
define('M2O_ROOT_PATH', './');
require M2O_ROOT_PATH . 'global.php';
$id = intval($_REQUEST['id']);
$dReturn = intval($_REQUEST['d_return']);
if ($id) {
    include M2O_ROOT_PATH . 'lib/class/vote.class.php';
    $obj = new vote();
    $vote = $obj->singleQuestionConti($id);
    // echo "<pre>";
    // print_r($vote);
    // echo "</pre>";exit;
    if ($dReturn) {
        echo json_encode($vote);
        exit;
    }
    $options = $vote['option_title'];
    //投票结果
    $html = '<ul class="vt_ul">';
    $i = 0;
    if (is_array($options) && count($options) > 0) {
        foreach ($options as $kk => $vv) {
            $i++;
            $precent = @round($vv['ini_single'] / $vote['question_total_ini'] * 100, 1);
            $rand = rand(1, 10);
            $html .= '<li class="vote-item-' . $vv['id'] . '"><div class="vote-option-li">' . $vv['title'] . ':</div> <div class="vote-option-outer-box"><div class="vote-option-inner-box vote-option-color' . $rand . '" style="width:' . $precent . '%;"></div></div> <div class="vote-option-text-box">(' . $precent . '%)<span>' . $vv['ini_single'] . ' 票</span></div></li>';
        }