Voting application

i want to you to help me get the votes selected in flash into php data

Page 1 of 1

2 Replies - 1306 Views - Last Post: 07 January 2010 - 09:43 AM Rate Topic: -----

#1 kilmer  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 07-January 10

Voting application

Post icon  Posted 07 January 2010 - 03:50 AM

//FLASH CODES TO GET VOTES

stop();
var loadVars_in:LoadVars = new LoadVars();
var loadVars_out:LoadVars = new LoadVars();
import mx.utils.Delegate;
import mx.controls.Alert;
var cbtSend:mx.controls.Button;
cbtSend.enabled = false;

listenerObject = new Object();
listenerObject.click = function(eventObject){
	cbtSend.enabled = true;
	};
	president.addEventListener("click", listenerObject);

cbtSend.onRelease = function() {
	  /* var oWarning:Object = new Object();
var sState:Number = president.selectedData;
	   loadVars_out.choice = sState;
	   trace(sState);
	   loadVars_out.sendAndLoad("vote1.php", loadVars_in, "POST");
gotoAndStop(3);
};



//PHP CODES TO RETRIEVE CODES AND SEND BACK TO FLASH
<?
//User, password & database
$user="root";
$password="";
$database="my_db";;
mysql_connect(localhost,$user,$password);
@mysql_select_db($database) or die( "Unable to connect to database");
$choice =$_POST['choice'];
// what choice did the user choose in flash?

if($choice == 1){
$query=mysql_query("UPDATE president SET vote1=vote1+1");
}
if($choice == 2){
$query=mysql_query("UPDATE president SET vote2=vote2+1");
}
if($choice == 3){
$query=mysql_query("UPDATE president SET vote3=vote3+1");
}
if($choice == 4){
$query=mysql_query("UPDATE president SET vote4=vote4+1");
}
//Get values from the database
$query="SELECT * FROM president";
$result=mysql_query($query);
mysql_close();
//What are the values from the database?
$vote1_out=mysql_result($result,0,"vote1");
$vote2_out=mysql_result($result,0,"vote2");
$vote3_out=mysql_result($result,0,"vote3");
$vote4_out=mysql_result($result,0,"vote4");
//Votes in total
$total=$vote1_out+$vote2_out+$vote3_out+$vote4_out;
//Info to send back to flash:
print"&totalVotes=$total&vote1total=$vote1_out&vote2total=$vote2_out&vote3total=$vote3_out&vote4total=$vote4_out";

?>



** Edit ** :code:

Is This A Good Question/Topic? 0
  • +

Replies To: Voting application

#2 no2pencil  Icon User is online

  • Toubabo Koomi
  • member icon

Reputation: 5247
  • View blog
  • Posts: 27,066
  • Joined: 10-May 07

Re: Voting application

Posted 07 January 2010 - 03:54 AM

Hello & welcome to Dream In Code!

What do you need help with ...?
Was This Post Helpful? 0
  • +
  • -

#3 ShaneK  Icon User is offline

  • require_once("brain.php"); //Fatal error :/
  • member icon

Reputation: 240
  • View blog
  • Posts: 1,224
  • Joined: 10-May 09

Re: Voting application

Posted 07 January 2010 - 09:43 AM

You need a flash programmer, not a PHP programmer.
Also, you should repeat your question in your post...and actually try not to have it all in your title...

Yours,
Shane~

This post has been edited by ShaneK: 07 January 2010 - 09:45 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1