0

This i sdriving me nuts and I know there should be an easy answer. Here is the php

$sql4 = 'select tranamt, tracct
          from bd.bdptran
          where bd.bdptran.trnum = 105 ';

$result4 = db2_exec($conn, $sql4);

while($row4 = db2_fetch_array($result4)) {
    echo $row4[0] ."<br />";
    echo $row4[1] ."<br />";
}

I get the results i want and it echo's like this
56.00
1A1
67.00
1A11A
45.00
1A10

The numbers are an array and the letter/numbers are another array.
My question is, how do i use the indivdual fields; meaning, say I just wanted to echo 56.00. Or 1A11A. How would I do that? I tried using foreach with an index number, but if I use the index[0] I will get a result of
5
1
6
1
4
1

Thanks guys.

2
Contributors
2
Replies
16
Views
3 Years
Discussion Span
Last Post by mc3330418
0

You could use db2_fetch_row() and db2_result(), check the first example in the documentation:

But instead of the loop, that moves the internal pointer to the next row, you can use an IF statement and get only the first row:

if(db2_fetch_row($result4))
{
    $number   = db2_result($result4, 0);
    $alphanum = db2_result($result4, 1);
}

# moving to the second row
db2_next_result($result4);

# repeat the previous IF statement
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.