depo136 Posted October 22, 2010 Share Posted October 22, 2010 Hi, learning as I go here, and I appreciate the help in advance .. I have some working php code that retrieves sql results using php. I assign the resutls to an array by doing this $bobreport = array(); while ($row=db2_fetch_array($querystmt)) { array_push($bobreport, $row); } i can then write the rows of returned data after some column headers using this... foreach ($bobreport as $value) { echo "<tr><td>$value[0]</td><td>$value[1] ..... } The particular report I'm working on now has a redundant date and time in every row that I omit in the foreach loop because I just want to show it once above the table somewhere. This doesn't seem to work in accomplishing that... echo "This data was updated ".$bobreport[0][9]." at ".$bobreport[0][10] ; All I seem to get in the report is "This data was updated at". Please help. Quote Link to comment https://forums.phpfreaks.com/topic/216589-trouble-getting-single-value-from-array/ Share on other sites More sharing options...
Colton.Wagner Posted October 22, 2010 Share Posted October 22, 2010 First off please use code tags for future posts. Are you sure your $querystmnt is correct? Also if you are going to set something as just $row with no array value then you must have you statement formed with a WHERE: $query = mysql_query("SELECT * FROM test WHERE id='1'"); I think the problem lies within your mysql but I can not tell. Thanks, Colton Wagner Quote Link to comment https://forums.phpfreaks.com/topic/216589-trouble-getting-single-value-from-array/#findComment-1125323 Share on other sites More sharing options...
depo136 Posted October 22, 2010 Author Share Posted October 22, 2010 My apologies, The report itself (and the table rows described) print fine (which therefore would imply my sql is fine. It's simply the fact that this echo "This data was updated ".$bobreport[0][9]." at ".$bobreport[0][10] ; shows as this .."This data was updated at" in the report. Quote Link to comment https://forums.phpfreaks.com/topic/216589-trouble-getting-single-value-from-array/#findComment-1125332 Share on other sites More sharing options...
PFMaBiSmAd Posted October 22, 2010 Share Posted October 22, 2010 Are you sure you have a [9] and [10] element in the zero'th row? What does the following show - echo '<pre>',print_r($bobreport,true),'</pre>'; Quote Link to comment https://forums.phpfreaks.com/topic/216589-trouble-getting-single-value-from-array/#findComment-1125334 Share on other sites More sharing options...
depo136 Posted October 22, 2010 Author Share Posted October 22, 2010 I'm not sure what I changed, but it works now. Row 0 did have the values. Thanks for the help! Quote Link to comment https://forums.phpfreaks.com/topic/216589-trouble-getting-single-value-from-array/#findComment-1125343 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.