forked from abusalam/Lok-Sabha-Election-16th
/
reserve.php
112 lines (85 loc) · 2.49 KB
/
reserve.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<?php
//include 'mysqliconn.php';
//include 'ppdata.php';
class reserve {
private $result;
private $msqli;
private $sobj;
function __construct($subd,$phase) {
// select QUERY ON A assembly TABLE
$this->sobj= new mysqliconn();
$this->msqli=$this->sobj->getconn();
$this->result = $this->msqli->query("SELECT a.forassembly as fasm, a.forsubdivision as fsub , a.forpc as fpc, a.number_of_member as memb, a.no_or_pc as npc, a.numb as pnumb , a.poststat as pst, b.no_party as ptyrqd FROM reserve a, `assembly_party` b WHERE a.forassembly = b.assemblycd AND a.forsubdivision = b.subdivisioncd AND a.number_of_member = b.no_of_member and a.forsubdivision='$subd' ") or die($this->msqli->error.__LINE__);
// GOING THROUGH THE DATA
$this->msqli->autocommit(FALSE);
//$sql = "update pers set groupid=?,booked=?,forassembly=?,forpc=?, where personcd=? ";
if ($phase==1)
{
$sql = "update personnela set groupid=?,booked=?,forassembly=?,selected=1 where personcd=? ";
}
else
{
$sql = "update personnela set groupid=?,booked=?,forassembly=? where personcd=? ";
}
//$sql = "update pers set booked=?,groupid=?,forasm=?,forpc=? where personcd=? ";
//$stmt = $mysqli->prepare("insert into test(testid) values(?)");
$this->stmt = $this->msqli->prepare($sql);
//echo "binding failed";
$this->stmt->bind_param('isss',$gpd,$bk,$fasm,$psd);
//$this->stmt->bind_param('issss',$gpd,$bk,$fasm,$fpc,$psd);
if($this->result->num_rows > 0) {
$i=0;
$k=0;
while($row = $this->result->fetch_assoc()) {
$fasm=$row['fasm'];
$sub=$row['fsub'];
$fpc=$row['fpc'];
$membno=$row['memb'];
$n_o_p=$row['npc'];
$p_numb=$row['pnumb'];
$pst=$row['pst'];
$preqd=$row['ptyrqd'];
if (strcmp($n_o_p,'N')==0)
{
$totres=$p_numb;
}
else
{
$totres=round($p_numb*$preqd/100,0);
}
/* echo $pst;
echo ' ';
echo $sub;
echo ' ';
echo $fasm;
echo ' ';
*/
$ppall1=new ppdata($fpc,$pst,$sub,$fasm,'S',$phase); // pp for subdivision
$bk='R';
$x=0;
$k=0;
//
while( $k<$totres)
{
if ($x< $ppall1->countnumb())
{
$psd=$ppall1->getperscdpp($x);
$gpd=$x;
$this->stmt->execute();
$x=$x+1;
}
else
{
break;
}
$k=$k+1;
}
$this->msqli->commit();
}
}
else {
echo 'Problem in reserve Formation ';
}
}
}
?>