 |
ประกาศตัวแปรไว้บนสุด แบบ Array แต่พอจะเอาข้อมุลมาใช้ มัน error ว่า <b>Notice</b>: Undefined index |
|
 |
|
|
 |
 |
|
ประกาศตัวแปรไว้บนสุด แบบ Array แต่พอจะเอาข้อมุลมาใช้ มัน error ว่า
<b>Notice</b>: Undefined index: general in <b>D:\Apache24\htdocs\Bootstrap\Statistics\Linegraph.php</b>
on line <b>159</b><br />
<br />
<b>Notice</b>: Undefined index: in <b>D:\Apache24\htdocs\Bootstrap\Statistics\Linegraph.php</b>
on line <b>159</b><br /> null
พร้อมกับบอกว่า Null
ช่วยแนะนำด้วยคะ
Code (PHP)
$data = array('year'=>array(),'general'=>array());
$data = array('year'=>array(),'insurance'=>array());
$data = array('year'=>array(),'partner'=>array());
for($year=$nowYear;$year>=$GraphYear;$year--)
{
$data['year'][] = (int)$year+543;
for($month=1;$month<=12;$month++)
{
$strBar_general=".......";
$strBar_insurance".......";
$strBar_partner".......";
$objBar_general = odbc_exec($conn,$strBar_general) or die ("Error SQL [".$strBar_general."]");
$objBar_insurance = odbc_exec($conn,$strBar_insurance) or die ("Error SQL [".$strBar_insurance."]");
$objBar_partner = odbc_exec($conn,$strBar_partner) or die ("Error SQL [".$strBar_partner."]");
$OPDLinegraph_general=(odbc_fetch_object($objBar_general));
$OPDLinegraph_general = !empty($OPDLinegraph_general) ? $OPDLinegraph_general->OPDLinegraph_general : 0;
$OPDLinegraph_insurance=(odbc_fetch_object($objBar_insurance));
$OPDLinegraph_insurance = !empty($OPDLinegraph_insurance) ? $OPDLinegraph_insurance->OPDLinegraph_insurance : 0;
$OPDLinegraph_partner=(odbc_fetch_object($objBar_partner));
$OPDLinegraph_partner = !empty($OPDLinegraph_partner) ? $OPDLinegraph_partner->OPDLinegraph_partner : 0;
//$OPDgeneral=0;
//$OPDinsurance=0;
//$OPDpartner=0;
$OPDgeneral = (int)$OPDLinegraph_general;
$OPDinsurance = (int)$OPDLinegraph_insurance;
$OPDpartner = (int)$OPDLinegraph_partner;
$data[$year+543]['general'][]= $OPDgeneral;
$data[$year+543]['insurance'][]= $OPDinsurance;
$data[$year+543]['partner'][]= $OPDpartner;
}
}
Code (PHP)
Array
(
[year] => Array
(
[0] => 2561
[1] => 2560
[2] => 2559
)
[partner] => Array
(
)
[2561] => Array
(
[general] => Array
(
[0] => 20946
[1] => 18876
[2] => 19824
[3] => 8922
[4] => 0
[5] => 0
[6] => 0
[7] => 0
[8] => 0
[9] => 0
[10] => 0
[11] => 0
)
[insurance] => Array
(
[0] => 10510
[1] => 9814
[2] => 10683
[3] => 4901
[4] => 0
[5] => 0
[6] => 0
[7] => 0
[8] => 0
[9] => 0
[10] => 0
[11] => 0
)
[partner] => Array
(
[0] => 13761
[1] => 13007
[2] => 14665
[3] => 6494
[4] => 0
[5] => 0
[6] => 0
[7] => 0
[8] => 0
[9] => 0
[10] => 0
[11] => 0
)
)
)
Code (PHP)
<script>
series: [
<?php
if(count($data)>0)
{
for($i=0;$i<count($data['year']);$i++)
{
?>
{
name: 'general',
data: <?=json_encode($data['year'][$data['general'][$i]])?>
},
{
name: 'insurance',
data: <?=json_encode($data['year'][$data['insurance'][$i]])?>
},
{
name: 'partner',
data: <?=json_encode($data['year'][$data['partner'][$i]])?>
},
<?php
}
}
?>
],
</script>
Code (PHP)
Error
series: [
{
name: 'general',
data: <br />
<b>Notice</b>: Undefined index: general in <b>D:\Apache24\htdocs\Bootstrap\nStatistics\Linegraph.php</b> on line <b>156</b><br />
<br />
<b>Notice</b>: Undefined index: in <b>D:\Apache24\htdocs\Bootstrap\Statistics\Linegraph.php</b> on line <b>156</b><br />null
},
{
name: 'insurance',
data: <br />
<b>Notice</b>: Undefined index: insurance in <b>D:\Apache24\htdocs\Bootstrap\Statistics\Linegraph.php</b> on line <b>160</b><br />
<br />
<b>Notice</b>: Undefined index: in <b>D:\Apache24\htdocs\Bootstrap\Statistics\Linegraph.php</b> on line <b>160</b><br />null
},
{
name: 'partner',
data: <br />
<b>Notice</b>: Undefined offset: 0 in <b>D:\Apache24\htdocs\Bootstrap\Statistics\Linegraph.php</b> on line <b>164</b><br />
<br />
<b>Notice</b>: Undefined index: in <b>D:\Apache24\htdocs\Bootstrap\Statistics\Linegraph.php</b> on line <b>164</b><br />
null
},
Tag : PHP, Ms SQL Server 2016
|
ประวัติการแก้ไข 2018-04-28 13:19:22
|
 |
 |
 |
 |
Date :
2018-04-28 13:17:59 |
By :
nottpoo |
View :
635 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
แนะนำให้ศึกษา Array แบบ multiple dimensions เพิ่มเติมน่ะครับ เพราะการเล่นกับข้อมูล array แบบหลายมิติ เราต้องเข้าใจหลัก การเข้าถึงข้อมูลในแต่ละชุดด้วย
Code (PHP)
<script>
series: [
<?php
if(count($data)>0)
{
for($i=0;$i<count($data['year']);$i++)
{
?>
{
name: 'general',
data: <?=json_encode($data[$data['year'][$i]]['general'])?>
},
{
name: 'insurance',
data: <?=json_encode($data[$data['year'][$i]]['insurance'])?>
},
{
name: 'partner',
data: <?=json_encode($data[$data['year'][$i]]['partner'])?>
},
<?php
}
}
?>
],
</script>
|
ประวัติการแก้ไข 2018-04-30 08:54:02 2018-04-30 09:38:26
 |
 |
 |
 |
Date :
2018-04-30 08:52:05 |
By :
mongkon.k |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|