function insert_pollresult($id)
{
    global $conn;
    # GET ANSWER OF VOTE CATE GORY
    $sql = "SELECT * from poll_question  where poll_id=' {$id['pollid']}'";
    $rsc = $conn->execute($sql);
    $poll_answer = $rsc->fields['poll_answer'];
    # SPLIT IN ARRAY
    $list = explode("|", $poll_answer);
    #COUT OF EACH CATEGORY
    for ($i = 0; $list[$i]; $i++) {
        $sql = "select count(*) as poll_id from vote_result WHERE answer='" . $list[$i] . "'";
        $rs = $conn->execute($sql);
        $Countlist[$i] = $rs->fields['poll_id'];
    }
    # CALCULATE THE PARCENTAGE
    return clulateParcentage($Countlist);
}
function view_vote($id)
{
    global $cp;
    global $conn;
    # GET ANSWER OF VOTE CATE GORY
    $sql = "SELECT * from poll_question  where poll_id='{$id}'";
    $rsc = $conn->execute($sql);
    $poll_answer = $rsc->fields['poll_answer'];
    # SPLIT IN ARRAY
    $list = explode("|", $poll_answer);
    #COUT OF EACH CATEGORY
    for ($i = 0; $list[$i]; $i++) {
        $sql = "select count(*) as poll_id from vote_result WHERE answer='" . $list[$i] . "'";
        $rs = $conn->execute($sql);
        $Countlist[$i] = $rs->fields[poll_id];
    }
    # CALCULATE THE PARCENTAGE
    $Countlist = clulateParcentage($Countlist);
    # CRETE NODE AND BACK TO PAVILION
    for ($i = 0; $list[$i]; $i++) {
        $a_result_node =& $cp->add_node("A1" . $i);
        $a_result_node->set_data($list[$i]);
    }
    # CRETE NODE AND BACK TO PAVILION
    for ($i = 0; 1; $i++) {
        $a_result_node =& $cp->add_node("P1" . $i);
        $a_result_node->set_data($Countlist[$i]);
        if ($Countlist[$i] == "") {
            break;
        }
    }
    $a_result_node =& $cp->add_node("count");
    $a_result_node->set_data($i);
}