Associative array can't fetch the last data.
Posted: Wed Dec 15, 2010 3:57 am
Hello,
Getting data from mysql and assign to associative array
Last data not assign to associative array.
for ex:
mysql query:
$qry = "
SELECT ci.itemType, SUM(ci.itemValue) AS itemValue
FROM count_info AS ci, s_info as si
WHERE si.`site_cd`=ci.`site_info`
AND ci.info_datetime BETWEEN '$date_start' AND '$date_end'
AND ci.adfile_uid='$ad_uid'
AND si.areacode = '$ph_code'
GROUP BY ci.itemType
ORDER BY ci.`itemtype`";
Result set:
itemType itemValue
MVC 942943
MTC 106503
SVC 213587
STC 1411050
php:
//define associative array
$as_arr = array('MVC'=>0, 'MTC'=>0,'SVC'=>0, 'STC'=>0);
All data assign perfectly, except last one[STC].
I'm getting the data by this way,
echo "MVC = " . $as_arr ['MVC']; // get data perferctly
echo "MTC = " . $as_arr ['MTC']; // get data perferctly
echo "SVC = " . $as_arr ['SVC']; // get data perferctly
echo "SRC = " . $as_arr ['SRC']; // NOT GETTING DATA
Code help please.
Where i did mistake? Please correct the code.
Thanks & Best Regards,
Thendral.
Getting data from mysql and assign to associative array
Last data not assign to associative array.
for ex:
mysql query:
$qry = "
SELECT ci.itemType, SUM(ci.itemValue) AS itemValue
FROM count_info AS ci, s_info as si
WHERE si.`site_cd`=ci.`site_info`
AND ci.info_datetime BETWEEN '$date_start' AND '$date_end'
AND ci.adfile_uid='$ad_uid'
AND si.areacode = '$ph_code'
GROUP BY ci.itemType
ORDER BY ci.`itemtype`";
Result set:
itemType itemValue
MVC 942943
MTC 106503
SVC 213587
STC 1411050
php:
//define associative array
$as_arr = array('MVC'=>0, 'MTC'=>0,'SVC'=>0, 'STC'=>0);
All data assign perfectly, except last one[STC].
I'm getting the data by this way,
echo "MVC = " . $as_arr ['MVC']; // get data perferctly
echo "MTC = " . $as_arr ['MTC']; // get data perferctly
echo "SVC = " . $as_arr ['SVC']; // get data perferctly
echo "SRC = " . $as_arr ['SRC']; // NOT GETTING DATA
Code help please.
Where i did mistake? Please correct the code.
Thanks & Best Regards,
Thendral.