|
 |
|
ช่วยแก้โค้ด poll ให้บันทึกลงฐานข้อมูล mssql ให้หน่อยครับ |
|
 |
|
|
 |
 |
|
Code (PHP)
<?php
$vote = $_REQUEST['vote'];
//get content of textfile
$filename = "poll_result.txt";
$content = file($filename);
//put content in array
$array = explode("||", $content[0]);
$yes = $array[0];
$no = $array[1];
$A = $array[2];
$B = $array[3];
$C = $array[4];
if ($vote == 0)
{
$yes = $yes + 1;
}
if ($vote == 1)
{
$no = $no + 1;
}
if ($vote == 2)
{
$A = $A + 1;
}
if ($vote == 3)
{
$B = $B + 1;
}
if ($vote == 4)
{
$C = $C + 1;
}
//insert votes to txt file
$insertvote = $yes."||".$no."||".$A."||".$B."||".$C;
$fp = fopen($filename,"w");
fputs($fp,$insertvote);
fclose($fp);
?>
<h2><img src="images/a1.jpg"></h2>
<table>
<tr>
<td>กกกก</td>
<td>
<img src="images/poll.gif"
width='<?php echo(100*round($yes/($no+$yes+$A+$B+$C),5)); ?>'
height='20'>
<?php echo(100*round($yes/($no+$yes+$A+$B+$C),5)); ?>%
</td>
</tr>
<tr>
<td><img src="images/a1.jpg"></td>
<td>
<img src="images/poll.gif"
width='<?php echo(100*round($no/($no+$yes+$A+$B+$C),5)); ?>'
height='20'>
<?php echo(100*round($no/($no+$yes+$A+$B+$C),5)); ?>%
</td>
</tr>
<td>?????</td>
<td>
<img src="images/poll.gif"
width='<?php echo(100*round($A/($no+$yes+$A+$B+$C),5)); ?>'
height='20'>
<?php echo(100*round($A/($no+$yes+$A+$B+$C),5)); ?>%
</td>
</tr>
<td>???????????</td>
<td>
<img src="images/poll.gif"
width='<?php echo(100*round($B/($no+$yes+$A+$B+$C),5)); ?>'
height='20'>
<?php echo(100*round($B/($no+$yes+$A+$B+$C),5)); ?>%
</td>
</tr>
<td>??????</td>
<td>
<img src="images/poll.gif"
width='<?php echo(100*round($C/($no+$yes+$A+$B+$C),5)); ?>'
height='20'>
<?php echo(100*round($C/($no+$yes+$A+$B+$C),5)); ?>%
</td>
</tr>
</table>
|
 |
 |
 |
 |
Date :
2010-09-16 08:52:57 |
By :
satonpanit |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 00
|