|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2003-01-23 04:28 UTC] mboeren@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 05:00:01 2025 UTC |
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"; }