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
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

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.