Jump to content

Trouble Getting Single Value From Array


depo136

Recommended Posts

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.

 

 

 

 

 

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/216589-trouble-getting-single-value-from-array/
Share on other sites

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

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.

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.