ID:               21836
 Updated by:       [EMAIL PROTECTED]
 Reported By:      [EMAIL PROTECTED]
-Status:           Open
+Status:           Bogus
 Bug Type:         Arrays related
 Operating System: Windows 2000
 PHP Version:      4.3.0
 New Comment:

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Since the returned array contains the columns both indexed (by
columnnumber) and associated (by fieldname) the columns seem to be
printed twice.
You can prevent this by using DBX_RESULT_INDEX as the third parameter
to dbx_query (provided you don't need the fieldnames).

Cheerio, Marc.



Previous Comments:
------------------------------------------------------------------------

[2003-01-23 03:53:40] [EMAIL PROTECTED]

I have a result from dbx_query that should be written in a table. The
outer foreach() runs thru the rows (correctly), the inner foreach()
thru the columns of every row. (Just like the example for foreach() in
the docu.)
My output are 4 cols(!), the 1st, the 2nd, and again the 1st and the
2nd. But I recieved only 2 columns from the database. When I use a
for() instead of foreach() (as commended out), it performs correctly.


$result = dbx_query($dbhandle, "SELECT emp_fname, emp_lname FROM
employee;");

foreach($result->data as $row)
{
  echo "<tr>\n";

  foreach($row as $field) {
    echo "<td>" . $field . "</td>\n"; }

  //for($i = 0; $i < $result->cols; $i++) {
  //  echo "<td>" . $row[$i] . "</td>\n"; }

  echo "</tr>\n";
}



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=21836&edit=1

Reply via email to