neverworks Posted June 23, 2010 Share Posted June 23, 2010 The following code: // Connect to the DB $link = connectToDB(); //$strXML will be used to store the entire XML document generated //Generate the graph element $strXML = "<graph xaxisname='Users' yaxisname='Quantity' hovercapbg='DEDEBE' hovercapborder='889E6D' caption='Report' divlinecolor='F47E00' numdivlines='6' vDivLineAlpha='30' showAreaBorder='1' areaBorderColor='000000' showNames='1' numVDivLines='29' vDivLineAlpha='30' formatNumberScale='0' rotateNames='1' decimalPrecision='0'>"; $strQuery = "SELECT b.em_emp_num as em_emp_num FROM bt.emp b WHERE b.em_dept_cd = 'SM' ORDER BY b.em_emp_num"; $result = odbc_exec($link, $strQuery) or die(odbc_error()); $strXML .= "<categories font='Arial' fontSize='11' fontColor='000000'>"; while(odbc_fetch_row($result)){ $strXML .= "<category name='" . odbc_result($result, 'em_emp_num') . "' />"; } $strXML .= "</categories>"; $strQuery2 = "SELECT b.bsc_status_cd FROM bt.blot_status_code b ORDER BY b.bsc_status_cd"; $result2 = odbc_exec($link, $strQuery2) or die(odbc_error()); while(odbc_fetch_row($result2)){ $colorID = getFCColor(); $result4 = reset($result); $strXML .= "<dataset seriesname='" . odbc_result($result2, 'bsc_status_cd') . "' color='" . $colorID ."' areaAlpha='50'>"; while(odbc_fetch_row($result4)){ $strQuery3 = "SELECT a.br_title_emp, a.br_status_cd, COUNT (a.br_status_cd) AS totals FROM bt.blot_record a WHERE a.br_title_emp = '" . odbc_result($result4, 'em_emp_num') . "' AND a.br_status_cd = '" . odbc_result($result2, 'bsc_status_cd') . "' AND TRUNC (a.br_process_date) >= (TRUNC (SYSDATE) - 30) GROUP BY a.br_title_emp, a.br_status_cd"; $result3 = odbc_exec($link, $strQuery3) or die(odbc_error()); $strXML .= "<set value='" . odbc_result($result3, 'TOTALS') . "' />"; } $strXML .= "</dataset>"; } /* Clear memory */ odbc_free_result($result); odbc_free_result($result2); /* Close DB link */ odbc_close($link); //Finally, close <graph> element $strXML .= "</graph>"; Produces the following XML output: <graph xaxisname='Users' yaxisname='Deeds' hovercapbg='DEDEBE' hovercapborder='889E6D' caption='Blotter Complete Output' subCaption='Number of Deeds Processed by User' divlinecolor='F47E00' numdivlines='6' vDivLineAlpha='30' showAreaBorder='1' areaBorderColor='000000' showNames='1' numVDivLines='29' vDivLineAlpha='30' formatNumberScale='0' rotateNames='1' decimalPrecision='0'><categories font='Arial' fontSize='11' fontColor='000000'><category name='2354' /><category name='2660' /><category name='2957' /><category name='3064' /><category name='3187' /><category name='3318' /><category name='3319' /><category name='3373' /><category name='3376' /><category name='3388' /><category name='3399' /><category name='3418' /><category name='3420' /><category name='3427' /><category name='3432' /><category name='3434' /><category name='3451' /><category name='3474' /><category name='3510' /><category name='3515' /><category name='3526' /><category name='3528' /><category name='3530' /><category name='3545' /><category name='3551' /><category name='3552' /><category name='3562' /><category name='3571' /><category name='3583' /><category name='3584' /><category name='3586' /><category name='3611' /><category name='3619' /><category name='3641' /><category name='3643' /><category name='3651' /><category name='3652' /><category name='3654' /><category name='3656' /></categories><dataset seriesname='C' color='AFD8F8' areaAlpha='50'></dataset><dataset seriesname='D' color='F6BD0F' areaAlpha='50'></dataset><dataset seriesname='E' color='8BBA00' areaAlpha='50'></dataset><dataset seriesname='F' color='A66EDD' areaAlpha='50'></dataset><dataset seriesname='G' color='F984A1' areaAlpha='50'></dataset><dataset seriesname='H' color='CCCC00' areaAlpha='50'></dataset><dataset seriesname='L' color='999999' areaAlpha='50'></dataset><dataset seriesname='M' color='0099CC' areaAlpha='50'></dataset><dataset seriesname='P' color='FF0000' areaAlpha='50'></dataset><dataset seriesname='R' color='006F00' areaAlpha='50'></dataset><dataset seriesname='S' color='0099FF' areaAlpha='50'></dataset><dataset seriesname='T' color='FF66CC' areaAlpha='50'></dataset><dataset seriesname='X' color='669966' areaAlpha='50'></dataset></graph> From what I can tell "while(odbc_fetch_row($result4)){" is returning FALSE and skipping the inside query. I think anyway. I want to avoid querying the $result array again and would rather re-use or copy it into another array that would be looped trough. Any assistance would be greatly appreciated. Thanks Link to comment https://forums.phpfreaks.com/topic/205683-need-assistance-with-array-and-loop/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.