Featured FLA
» Author: Bugra Ozden
» Title: Skatalog v9 - product catalog
» Description: Create your product catalog easly and publish on your website or Create your image gallery, documents list, portfolio. Fully XML Driven
» More by Bugra Ozden
Featured Site
» Posted in the Flash Kit Links section
» Title: Creative DW Image Show PRO
» Description: Creative DW Image Show PRO is a Dreamweaver extension which enables the user to create multimedia presentations. It combines the features of the popular Creative DW Image Show with the ability to add professional text effects to slides (similar to After Effects). The product is very customizable: the user can choose the duration of the transition effects, the slide motion start and end position, zoom and panning type for both images and texts.
<?
//////// IMPORTANT!!! ///////////////////////////////////////
//change the parameters to match your database
$conn = mysql_connect("localhost","","") or die(mysql_error());
mysql_select_db("test", $conn) or die(mysql_error());
////////////////////////////////////////////////////////////////////////////////////////////////////
//the rest doesn't have to be changed…
session_start();
//ako nije jos dat glas, pokazi formular
if(!session_is_registered("vote_request")){
//show poll form
//concate form strings
$poll_form = "
\n";
//if the poll form is submitted
if($REQUEST_METHOD == "POST"){
//register voter to deny more votes
session_register("vote_request");
//update table
mysql_query("UPDATE anketa_odg SET hits = hits + 1 WHERE odg_id = ".$_POST[answer]);
//get values from db and show it in swf
//first we must find the id of the last inserted question
$db_data = mysql_fetch_array(mysql_query("SELECT MAX(poll_id) AS max_id FROM anketa_pit"));
//id of the last question
$last_que_id = $db_data[max_id];
//get question
$rez = mysql_query("SELECT pitanje FROM anketa_pit WHERE poll_id = ".$last_que_id);
//fetch question
$question_data = mysql_fetch_array($rez);
$question = $question_data[pitanje];
//get num of all answers to that question
$rez = mysql_query("SELECT SUM(hits) as all_hits FROM anketa_odg WHERE poll_id = ".$last_que_id);
//fetch result
$data = mysql_fetch_array($rez);
//num of all hits
$num_ans = $data[all_hits];
//free some memory
mysql_free_result($rez);
//get all possible answers
$rez = mysql_query("SELECT odgovor, hits FROM anketa_odg WHERE poll_id = ".$last_que_id);
//counter variable
$i = 1;
//init. flash vars
$flash_vars = "question=".$question."&";
//fetch answer from db and add them to form
while($ans_dta = mysql_fetch_array($rez)){
$flash_vars .= "odgovor".$i."=".$ans_dta[odgovor]."&proc".$i."=".round((intval($ans_dta[hits])/intval($num_ans))*100)."&br_gl".$i."=".$ans_dta[hits]."&";
$i++;
}
//free some memory
mysql_free_result($rez);
//pokreni pop up zajedno sa varijablama
echo "";
//zapamti varijable
session_register("flash_vars");
echo "view results";
} else {
//add form or link to template
echo $poll_form;
}
} else {
//show link to view only the results
echo "view results";
}
?>
That’s the code required for the poll, if you want to use it as a module on a page, simply put the code above into your own php script and separate it with blocks, like this: