Exemplo n.º 1
0
<!DOCTYPE html>
<?php 
//include database connection to the script
include "\\connection.php";
include "\\algo.php";
$a = new pics();
$b = new pics();
$pick_gen = rand(0, 1);
if ($pick_gen == 0) {
    //select gender on random
    $a->gender = "boys";
    $b->gender = "boys";
} else {
    $a->gender = "girls";
    $b->gender = "girls";
}
$a->sel_dir();
$b->sel_dir();
$a->sel_random($conn);
$b->sel_least($conn);
?>

<html>
<head>
	<title>disha-bq</title>
	<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<script>		//use ajax to send win lose info and run php in another file
var aID,bID,gender;
aID  = "<?php 
Exemplo n.º 2
0
    {
        $this->rate = $this->rate + $this->k * ($this->weight - $this->exp);
        $this->sql = "UPDATE {$this->gender} SET RATING={$this->rate} WHERE ID={$this->id}";
        $conn->query($this->sql);
    }
    function cal_k()
    {
        if ($this->gender === "boys") {
            $this->k = 533;
        } else {
            $this->k = 417;
        }
    }
}
$win = new pics();
$lose = new pics();
$win->gender = $_REQUEST["gender"];
$lose->gender = $_REQUEST["gender"];
$win->cal_k();
$lose->cal_k();
$win->id = intval($_REQUEST["win"]);
$lose->id = intval($_REQUEST["lose"]);
$win->get_rate($conn);
$lose->get_rate($conn);
$win->get_expect($lose->rate);
$lose->get_expect($win->rate);
$win->weight = 1;
$lose->weight = 0;
$win->new_rate($conn);
$lose->new_rate($conn);
echo $win->k . "<br>";