|
|
|
สอบถามหน่อยครับ พอดีทำค้นหาตามเดือนและปีแล้วค้นหาเดือนที่มีข้อมูล error ยกเว้นเดือน 11 |
|
|
|
|
|
|
|
ผมลงข้อมูลไว้เดือน 10 11 12 ครับแล้ว ผมได้ทำการค้นหา ตามเดือน เริ่มจาก เดือน 10 และ 12 ไม่มีค่าออกมาเลย ทั้งที่มีข้อมูลอยู่ ขึ้นเป็น error แทน แต่เดือน 11 ข้อมูลมาครบครับ เป็นเพราะอะไรครับ ขอผู้รู้ช่วยแนะนำทีครับ
Code (PHP)
<?php
include("Config.php");
$year=date('Y');
@$month=$_POST['re_month'];
@$y=$_POST['re_year'];
?>
<br>
<br>
<br>
<p align="center"><a style="cursor:pointer" onclick="printDiv('divprint')" ><u><font color="#CCCCCC"> Print Report </font></u></a></p>
<center>
<form name="f1" method="post" action="show.php">
Search <select name="re_month">
<option value="01" selected='selected'>January</option>
<option value="02" >February</option>
<option value="03" >March</option>
<option value="04" >April</option>
<option value="05" >May</option>
<option value="06" >June</option>
<option value="07" >July</option>
<option value="08" >August</option>
<option value="09" >September</option>
<option value="10" >October</option>
<option value="11" >November</option>
<option value="12" >December</option>
</select>
<input type="submit" name="submit" value="Send Month">
</form><form name="f2" method="post" action="show.php">
<select name="re_year">
<?php
for($i=2015;$i<=$year;$i++){
?>
<option value="<?=$i?>"><?=$i?></option>
<? }
?>
</select>
<input type="submit" name="submit2" value="Send Year">
</form>
</center>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="https://www.google.com/jsapi?autoload={'modules':[{'name':'visualization','version':'1.1','packages':['corechart']}]}"></script>
<title>Questionnaire</title>
<link href="css/styles.css" rel="stylesheet" type="text/css">
</head>
<body leftmargin="0" topmargin="0">
<br>
<br>
<?php
$sql="SELECT date,company,visiting,chk1,chk2,chk3,chk4,chk5,chk6,chk7,chk8,chk9,chk10 FROM tb_person WHERE MONTH(date)='$month' OR YEAR(date) = '$y'";
$result=mysql_query($sql) or die(mysql_error());
$sqllist = mysql_fetch_array($result);
if(!$sqllist){
echo "<br><div class='alert alert-danger' align=center>ไม่มีข้อมูลของเดือนนี้</div>";
}
else{
?>
<div id="divprint">
<center>
<form name="f1" method="post" action="show.php">
<table width="900" border="0" cellpadding="3" cellspacing="1" bgcolor="#8595a3">
<tr bgcolor="#FFFFFF">
<td><center>
<table width="100%" border="1" cellspacing="0" cellpadding="3">
<tr>
<td><img src="images/head.png" width="900" height="150"></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr><td><strong>* Star Point: 5 stars =Excellent, 4 stars = Very good, 3 stars = Good, 2 stars = Fair and 1 stars = Poor</strong></td></tr>
</table></td>
</tr>
<tr>
<td><hr color="#999999" noshade="noshade" size="1" style="border-style:dashed " /></td>
</tr>
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="3">
<tr>
<td colspan="2">
<table width="100%" border="1" cellpadding="0" cellspacing="0" bgcolor="#8595a3">
<tr align="center" bgcolor="#CCCCCC">
<td rowspan="2"><B>Date</B></td>
<td rowspan="2"><B>Company</B></td>
<td rowspan="2"><B>Visiting Purpose</B></td>
<td colspan="4"><B>The staff is friendly and helpful</B></td>
<td colspan="4"><B>Presentation and documentation of the product</B></td>
<td colspan="5"><B>Ability to respond to the technical question</B></td>
</tr>
<tr align="center" bgcolor="#CCCCCC">
<td width="5%"><strong>1</strong></td>
<td width="5%"><strong>2</strong></td>
<td width="5%"><strong>3</strong></td>
<td width="5%"><strong>Total</strong></td>
<td width="5%"><strong>1</strong></td>
<td width="5%"><strong>2</strong></td>
<td width="5%"><strong>3</strong></td>
<td width="5%"><strong>Total</strong></td>
<td width="5%"><strong>1</strong></td>
<td width="5%"><strong>2</strong></td>
<td width="5%"><strong>3</strong></td>
<td width="5%"><strong>4</strong></td>
<td width="5%"><strong>Total</strong></td>
</tr>
</tr>
<?php
$i=0;
while(list($date,$company,$visiting,$chk1,$chk2,$chk3,$chk4,$chk5,$chk6,$chk7,$chk8,$chk9,$chk10) = mysql_fetch_row($result)){
?>
<tr bgcolor="#FFFFFF" align='center'>
<td><? $newDate = date("d-m-Y", strtotime($date));
echo $newDate;
?></td>
<td><? $str = $company;
$cut = substr($str,0,6);
echo $cut;
?></td>
<td><? $str = $visiting;
$cut2 = substr($str,0,6);
echo $cut2;
?></td>
<td><? echo $chk1 ?></td>
<td><? echo $chk2 ?></td>
<td><? echo $chk3 ?></td>
<? $chk123 = ($chk1+$chk2+$chk3)/3; ?>
<td><? echo number_format($chk123, 2, '.', '') ?></td>
<td><? echo $chk4 ?></td>
<td><? echo $chk5 ?></td>
<td><? echo $chk6 ?></td>
<? $chk456 = ($chk4+$chk5+$chk6)/3; ?>
<td><? echo number_format($chk456, 2, '.', '') ?></td>
<td><? echo $chk7 ?></td>
<td><? echo $chk8 ?></td>
<td><? echo $chk9 ?></td>
<td><? echo $chk10 ?></td>
<? $chk78910 = ($chk7+$chk8+$chk9+$chk10)/4; ?>
<td><? echo number_format($chk78910, 2, '.', '') ?></td>
</tr>
<?php
@$total1 += $chk123;
@$total2 += $chk456;
@$total3 += $chk78910;
$sumchk = 5;
?>
<? $i++; } ?>
<tr align='right'>
<td colspan="3">Average</td>
<td colspan="4"><? echo number_format($total1/$i, 2, '.', '') ?></td>
<td colspan="4"><? echo number_format($total2/$i, 2, '.', '') ?></td>
<td colspan="5"><? echo number_format($total3/$i, 2, '.', '') ?></td>
<tr align='right'>
<td colspan="3">%</td>
<td colspan="4"><? echo number_format(($total1/$i)*100/$sumchk, 2, '.', '') ?>%</td>
<td colspan="4"><? echo number_format(($total2/$i)*100/$sumchk, 2, '.', '') ?>%</td>
<td colspan="5"><? echo number_format(($total3/$i)*100/$sumchk, 2, '.', '') ?>%</td>
</tr>
</tr>
</tr>
</table>
</td>
</tr>
</table>
</td>
</table>
</center>
</td>
</table>
<br>
<br>
<br>
</form>
<div id="piechart" style="width:950px; height: 500px;"></div>
</center>
</div>
<?php } ?>
</body>
</html>
<script type="text/javascript">
function printDiv(divName) {
var printContents = document.getElementById(divName).innerHTML;
var originalContents = document.body.innerHTML;
document.body.innerHTML = printContents;
window.print();
document.body.innerHTML = originalContents;
}
</script>
<script type="text/javascript">
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Task', 'Hours per Day'],
['The staff is friendly and helpful',<?php echo $total1/$i ?>],
['Presentation and documentation of the product',<?php echo $total2/$i ?>],
['Ability to respond to the technical question',<?php echo $total3/$i ?>],
]);
var options = {
title: ''
};
var chart = new google.visualization.PieChart(document.getElementById('piechart'));
chart.draw(data, options);
}
</script>
Tag : PHP, MySQL, JavaScript
|
ประวัติการแก้ไข 2015-11-18 15:31:11 2015-11-18 15:37:20
|
|
|
|
|
Date :
2015-11-18 12:40:08 |
By :
kittisak30 |
View :
793 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
สีแดงครอบโค๊ดหน่อยครับ
|
|
|
|
|
Date :
2015-11-18 15:03:33 |
By :
NewbiePHP |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 05
|