Hello Everyone,
I’m new to php and we wanted to have a raffle system for the Christmas party. I found a system and modified to my needs, but I cant make it work. any ideas.
raffle page
[php]
Christmas Party Raffle
.raffle{width:300px; margin:60px auto; text-align:center}
#roll{height:32px; line-height:32px; margin-bottom:10px; font-size:24px; color:#f30}
#stop{display:yes}
#result{margin-top:20px; line-height:24px; font-size:16px; text-align:center}
[/php]
data.php
[php]<?php include_once('connect.php'); //connect db ?>
<?php
$action = $_GET['action'];
if($action==""){ //read date, return json
$query = mysql_query("select * from employees where status=0");
while($row=mysql_fetch_array($query)){
$arr[] = array(
'id' => $row['id'],
'name' => $row['name'],
);
}
echo json_encode($arr);
}else{ //Identification winning name
$id = $_POST['id'];
$sql = "update employees set status=1 where id=$id";
$query = mysql_query($sql);
if($query){
echo '1';
}
}
?>[/php]
mysql table
[php]CREATE TABLE employees
(
id
int(11) NOT NULL auto_increment,
name
varchar(20) NOT NULL,
status
tinyint(1) NOT NULL default ‘0’,
PRIMARY KEY (id
)
) ENGINE=MyISAM DEFAULT CHARSET=utf8; [/php]