深圳全飞鸿
标题:
mysqli_next_result会导致死循环
[打印本页]
作者:
zhgc
时间:
2019-12-23 16:43
标题:
mysqli_next_result会导致死循环
以前的方法:
while( !mysqli_next_result( $db ) )
{
$result = mysqli_store_result( $db );
mysqli_free_result($result);
}
改为
do
{
if ($result=mysqli_store_result($db))
{
mysqli_free_result($result);
}
} while (mysqli_next_result($db));
作者:
zhgc
时间:
2019-12-23 16:44
首次用于安徽看板
<?php
error_reporting(0);
//$agile_include_path = dirname(__FILE__) . '/../php/';
//set_include_path(get_include_path() . PATH_SEPARATOR . $agile_include_path);
//require_once('agilelib.php');
//date_default_timezone_set('America/Los_Angeles');
require_once(dirname(__FILE__) . '/../php/kb_config.inc.php');
$kbconf=new kb_config();
?>
<html>
<head>
<meta http-equiv=Content-Type content=text/html;charset=utf8>
<meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=yes" />
</head>
<style type="text/css">
body {
margin:0.5%;
font-size:150%;
font: normal 100% Helvetica, Arial, sans-serif;
color:black;
background-color: white
}
h1 {
font-size: 1.5em;
}
small {
font-size: 0.875em;
}
table.gridtable {
font-family: verdana,arial,sans-serif;
font-size:18px;
border-width: 1px;
border-color: #666666;
border-collapse: collapse;
}
table.gridtable th {
border-width: 1px;
padding: 8px;
border-style: solid;
border-color: #666666;
}
table.gridtable td {
border-width: 1px;
padding: 8px;
border-style: solid;
border-color: #666666;
}
td.tdtitle {
FONT-WEIGHT: bold;
text-align:center;
vertical-align:middle;
FONT-SIZE: 1.5em;
}
td.tdtext {
text-align:center;
vertical-align:middle;
}
</style>
<body>
<?php
$line=$kbconf->line;
/*
*/
$param=array(
// database server
"db_host"=>$kbconf->database,
"db_username"=>"report",
"db_password"=>"report",//"why do you want to crack my password? contact me 13760216621",
"db_database"=>"sfc",
"db_charset"=>"UTF8",
);
$db = mysqli_connect($param["db_host"], $param["db_username"], $param["db_password"]);
if (!$db) {
die("prepare_db: ".mysqli_connect_error());
}else
{
}
$data=array(
"line"=>array(
"hstd"=>0, //每小时的标准,班/10得到
"day"=>"",
"time"=>"",
"week"=>"",
"data1"=>$line,
"data2"=>"未生产",
"data3"=>"0",
"data4"=>"0",
"data5"=>"0",
"data6"=>"0",
),
"r102"=>array( //"08:00","09:00","10:00","11:00","13:00","14:00","15:00","16:00","18:00","19:00","20:00"
"8"=>array("T"=>"08:00","C3"=>0,"C4"=>0),
"9"=>array("T"=>"09:00","C3"=>0,"C4"=>0),
"10"=>array("T"=>"10:00","C3"=>0,"C4"=>0),
"11"=>array("T"=>"11:00","C3"=>0,"C4"=>0),
"13"=>array("T"=>"13:00","C3"=>0,"C4"=>0),
"14"=>array("T"=>"14:00","C3"=>0,"C4"=>0),
"15"=>array("T"=>"15:00","C3"=>0,"C4"=>0),
"16"=>array("T"=>"16:00","C3"=>0,"C4"=>0),
"18"=>array("T"=>"18:00","C3"=>0,"C4"=>0),
"19"=>array("T"=>"19:00","C3"=>0,"C4"=>0),
)
);
$sql="call sfc.KANBAN_01_XCAH('{$line}');";
$result = mysqli_query($db,$sql); //must have $con parameter
if($row = mysqli_fetch_assoc($result)){
$data["line"]=$row;
$data["line"]["hstd"]=$data["line"]["data5"]*1 / 10;
//echo $data["line"]["hstd"];
/* Array(
[day] => 20191007
[time] => 上午 00:00
[week] => 星期一
[data1] => L6
[data2] => IPC019_A01
[data3] => 7885
[data4] => 4947
[data5] => 7885
[data6] => 100.00
)*/
}
mysqli_free_result($result);
//fix by syant
/*while( !mysqli_next_result( $db ) )
{
$result = mysqli_store_result( $db );
mysqli_free_result($result);
}*/
do
{
if ($result=mysqli_store_result($db))
{
mysqli_free_result($result);
}
} while (mysqli_next_result($db));
$sql="select * from sfc.p_tmp600_t order by c1,c2*1";
$result = mysqli_query($db,$sql); //must have $con parameter
while($row = mysqli_fetch_assoc($result)){
/*Array(
[C1] => 20191006
[C2] => 10
[C3] => 429
[C4] => 210
[C5] =>
[C6] => )*/
$hour=$row["C2"]*1;
if($hour<8){
//夜班的不做处理.
}else if($hour==12){
$data["r102"]["11"]["C3"]=$data["r102"]["11"]["C3"]*1+$row["C3"]*1;
$data["r102"]["11"]["C4"]=$data["r102"]["11"]["C4"]*1+$row["C4"]*1;
}else if($hour==17){
$data["r102"]["16"]["C3"]=$data["r102"]["16"]["C3"]*1+$row["C3"]*1;
$data["r102"]["16"]["C4"]=$data["r102"]["16"]["C4"]*1+$row["C4"]*1;
}else if($hour>19){
$data["r102"]["19"]["C3"]=$data["r102"]["19"]["C3"]*1+$row["C3"]*1;
$data["r102"]["19"]["C3"]=$data["r102"]["19"]["C4"]*1+$row["C4"]*1;
} else {
if(array_key_exists($row["C2"],$data["r102"])){
$data["r102"][$row["C2"]]["C3"]=$row["C3"]*1;
$data["r102"][$row["C2"]]["C4"]=$row["C4"]*1;
}
}
}
mysqli_free_result($result);
mysqli_close($db);
//--
require_once('chart_1.php');
/*
print_r($data["r102"]);
Array
(
[8] => Array
(
[C1] => 20191006
[C2] => 8
[C3] => 574
[C4] => 178
[C5] =>
[C6] =>
)*/
?>
<table style="width: 100%; height: 100%;" border=0 >
<tr style="height: 2%;"><td>
<!-- 第一行标题栏 -->
<DIV style="width: 100%; height: 8%; background-color: transparent; text-align: center">
<span style="COLOR: #222222; FONT-SIZE: 1em; FONT-FAMILY: Verdana" ><?php echo date('H:i:s',time()); ?> </span>
<SPAN id=title style="FONT-WEIGHT: bold; FONT-SIZE: 2.5em; COLOR: black; FONT-FAMILY: Microsoft YaHei" >安徽协创-实时产出看板</SPAN>
<span style="COLOR: #ffffff; FONT-SIZE: 1em; FONT-FAMILY: Verdana" ><?php echo date('Y-m-d H:i:s',time()); ?> </span>
</DIV>
</td></tr>
<tr><td>
<!-- 第二行图表栏 -->
<font color =black>
<table border=1 style="width: 100%; height: 100%;" class='gridtable'>
<tr style="height: 8%;">
<td width="7%" noWrap class='tdtitle'> 机种</td> <td noWrap class='tdtext'> <?php echo $data["line"]["data2"]; ?> </td>
<td noWrap class='tdtitle'>线别</td> <td noWrap class='tdtext'> <?php echo $data["line"]["data1"]; ?> </td>
<td noWrap class='tdtitle'>目标产出</td> <td noWrap class='tdtext'> <?php echo $data["line"]["data5"]; ?> </td>
<td noWrap class='tdtitle'>实际投入</td> <td noWrap class='tdtext'> <?php echo $data["line"]["data3"]; ?> </td>
<td noWrap class='tdtitle'>实际产出</td> <td noWrap class='tdtext'> <?php echo $data["line"]["data4"]; ?> </td>
<?php
$itarget=$data["line"]["data6"]*1.00;
if($itarget>=100){
echo "<td noWrap class='tdtitle'>产出达成率</td> <td noWrap class='tdtext' bgcolor='#92D050'>".$data["line"]["data6"]."</td>";
} else if ($itarget>=90){
echo "<td noWrap class='tdtitle'>产出达成率</td> <td noWrap class='tdtext' bgcolor='#FFFF2E'>".$data["line"]["data6"]."</td>";
} else {
echo "<td noWrap class='tdtitle'>产出达成率</td> <td noWrap class='tdtext' bgcolor='#FF3C3C'>".$data["line"]["data6"]."</td>";
}
?>
<td noWrap class='tdtitle'>日期</td> <td noWrap class='tdtext'> <?php echo date('Y-m-d',time()); ?> </td>
</tr>
<tr><td colspan=14 style="vertical-align:middle;text-align:center;">
<img src='../pictures/ahxc.png?r=11' style="width: 100%; height: auto;" />
</td></tr>
</table>
</font>
</td></tr>
</table>
</body>
</html>
复制代码
作者:
zhgc
时间:
2019-12-23 16:44
首次用于安徽看板
<?php
error_reporting(0);
//$agile_include_path = dirname(__FILE__) . '/../php/';
//set_include_path(get_include_path() . PATH_SEPARATOR . $agile_include_path);
//require_once('agilelib.php');
//date_default_timezone_set('America/Los_Angeles');
require_once(dirname(__FILE__) . '/../php/kb_config.inc.php');
$kbconf=new kb_config();
?>
<html>
<head>
<meta http-equiv=Content-Type content=text/html;charset=utf8>
<meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=yes" />
</head>
<style type="text/css">
body {
margin:0.5%;
font-size:150%;
font: normal 100% Helvetica, Arial, sans-serif;
color:black;
background-color: white
}
h1 {
font-size: 1.5em;
}
small {
font-size: 0.875em;
}
table.gridtable {
font-family: verdana,arial,sans-serif;
font-size:18px;
border-width: 1px;
border-color: #666666;
border-collapse: collapse;
}
table.gridtable th {
border-width: 1px;
padding: 8px;
border-style: solid;
border-color: #666666;
}
table.gridtable td {
border-width: 1px;
padding: 8px;
border-style: solid;
border-color: #666666;
}
td.tdtitle {
FONT-WEIGHT: bold;
text-align:center;
vertical-align:middle;
FONT-SIZE: 1.5em;
}
td.tdtext {
text-align:center;
vertical-align:middle;
}
</style>
<body>
<?php
$line=$kbconf->line;
/*
*/
$param=array(
// database server
"db_host"=>$kbconf->database,
"db_username"=>"report",
"db_password"=>"report",//"why do you want to crack my password? contact me 13760216621",
"db_database"=>"sfc",
"db_charset"=>"UTF8",
);
$db = mysqli_connect($param["db_host"], $param["db_username"], $param["db_password"]);
if (!$db) {
die("prepare_db: ".mysqli_connect_error());
}else
{
}
$data=array(
"line"=>array(
"hstd"=>0, //每小时的标准,班/10得到
"day"=>"",
"time"=>"",
"week"=>"",
"data1"=>$line,
"data2"=>"未生产",
"data3"=>"0",
"data4"=>"0",
"data5"=>"0",
"data6"=>"0",
),
"r102"=>array( //"08:00","09:00","10:00","11:00","13:00","14:00","15:00","16:00","18:00","19:00","20:00"
"8"=>array("T"=>"08:00","C3"=>0,"C4"=>0),
"9"=>array("T"=>"09:00","C3"=>0,"C4"=>0),
"10"=>array("T"=>"10:00","C3"=>0,"C4"=>0),
"11"=>array("T"=>"11:00","C3"=>0,"C4"=>0),
"13"=>array("T"=>"13:00","C3"=>0,"C4"=>0),
"14"=>array("T"=>"14:00","C3"=>0,"C4"=>0),
"15"=>array("T"=>"15:00","C3"=>0,"C4"=>0),
"16"=>array("T"=>"16:00","C3"=>0,"C4"=>0),
"18"=>array("T"=>"18:00","C3"=>0,"C4"=>0),
"19"=>array("T"=>"19:00","C3"=>0,"C4"=>0),
)
);
$sql="call sfc.KANBAN_01_XCAH('{$line}');";
$result = mysqli_query($db,$sql); //must have $con parameter
if($row = mysqli_fetch_assoc($result)){
$data["line"]=$row;
$data["line"]["hstd"]=$data["line"]["data5"]*1 / 10;
//echo $data["line"]["hstd"];
/* Array(
[day] => 20191007
[time] => 上午 00:00
[week] => 星期一
[data1] => L6
[data2] => IPC019_A01
[data3] => 7885
[data4] => 4947
[data5] => 7885
[data6] => 100.00
)*/
}
mysqli_free_result($result);
//fix by syant
/*while( !mysqli_next_result( $db ) )
{
$result = mysqli_store_result( $db );
mysqli_free_result($result);
}*/
do
{
if ($result=mysqli_store_result($db))
{
mysqli_free_result($result);
}
} while (mysqli_next_result($db));
$sql="select * from sfc.p_tmp600_t order by c1,c2*1";
$result = mysqli_query($db,$sql); //must have $con parameter
while($row = mysqli_fetch_assoc($result)){
/*Array(
[C1] => 20191006
[C2] => 10
[C3] => 429
[C4] => 210
[C5] =>
[C6] => )*/
$hour=$row["C2"]*1;
if($hour<8){
//夜班的不做处理.
}else if($hour==12){
$data["r102"]["11"]["C3"]=$data["r102"]["11"]["C3"]*1+$row["C3"]*1;
$data["r102"]["11"]["C4"]=$data["r102"]["11"]["C4"]*1+$row["C4"]*1;
}else if($hour==17){
$data["r102"]["16"]["C3"]=$data["r102"]["16"]["C3"]*1+$row["C3"]*1;
$data["r102"]["16"]["C4"]=$data["r102"]["16"]["C4"]*1+$row["C4"]*1;
}else if($hour>19){
$data["r102"]["19"]["C3"]=$data["r102"]["19"]["C3"]*1+$row["C3"]*1;
$data["r102"]["19"]["C3"]=$data["r102"]["19"]["C4"]*1+$row["C4"]*1;
} else {
if(array_key_exists($row["C2"],$data["r102"])){
$data["r102"][$row["C2"]]["C3"]=$row["C3"]*1;
$data["r102"][$row["C2"]]["C4"]=$row["C4"]*1;
}
}
}
mysqli_free_result($result);
mysqli_close($db);
//--
require_once('chart_1.php');
/*
print_r($data["r102"]);
Array
(
[8] => Array
(
[C1] => 20191006
[C2] => 8
[C3] => 574
[C4] => 178
[C5] =>
[C6] =>
)*/
?>
<table style="width: 100%; height: 100%;" border=0 >
<tr style="height: 2%;"><td>
<!-- 第一行标题栏 -->
<DIV style="width: 100%; height: 8%; background-color: transparent; text-align: center">
<span style="COLOR: #222222; FONT-SIZE: 1em; FONT-FAMILY: Verdana" ><?php echo date('H:i:s',time()); ?> </span>
<SPAN id=title style="FONT-WEIGHT: bold; FONT-SIZE: 2.5em; COLOR: black; FONT-FAMILY: Microsoft YaHei" >安徽协创-实时产出看板</SPAN>
<span style="COLOR: #ffffff; FONT-SIZE: 1em; FONT-FAMILY: Verdana" ><?php echo date('Y-m-d H:i:s',time()); ?> </span>
</DIV>
</td></tr>
<tr><td>
<!-- 第二行图表栏 -->
<font color =black>
<table border=1 style="width: 100%; height: 100%;" class='gridtable'>
<tr style="height: 8%;">
<td width="7%" noWrap class='tdtitle'> 机种</td> <td noWrap class='tdtext'> <?php echo $data["line"]["data2"]; ?> </td>
<td noWrap class='tdtitle'>线别</td> <td noWrap class='tdtext'> <?php echo $data["line"]["data1"]; ?> </td>
<td noWrap class='tdtitle'>目标产出</td> <td noWrap class='tdtext'> <?php echo $data["line"]["data5"]; ?> </td>
<td noWrap class='tdtitle'>实际投入</td> <td noWrap class='tdtext'> <?php echo $data["line"]["data3"]; ?> </td>
<td noWrap class='tdtitle'>实际产出</td> <td noWrap class='tdtext'> <?php echo $data["line"]["data4"]; ?> </td>
<?php
$itarget=$data["line"]["data6"]*1.00;
if($itarget>=100){
echo "<td noWrap class='tdtitle'>产出达成率</td> <td noWrap class='tdtext' bgcolor='#92D050'>".$data["line"]["data6"]."</td>";
} else if ($itarget>=90){
echo "<td noWrap class='tdtitle'>产出达成率</td> <td noWrap class='tdtext' bgcolor='#FFFF2E'>".$data["line"]["data6"]."</td>";
} else {
echo "<td noWrap class='tdtitle'>产出达成率</td> <td noWrap class='tdtext' bgcolor='#FF3C3C'>".$data["line"]["data6"]."</td>";
}
?>
<td noWrap class='tdtitle'>日期</td> <td noWrap class='tdtext'> <?php echo date('Y-m-d',time()); ?> </td>
</tr>
<tr><td colspan=14 style="vertical-align:middle;text-align:center;">
<img src='../pictures/ahxc.png?r=11' style="width: 100%; height: auto;" />
</td></tr>
</table>
</font>
</td></tr>
</table>
</body>
</html>
复制代码
欢迎光临 深圳全飞鸿 (http://www.nagomes.com/disc/)
Powered by Discuz! X3.2