PHP  
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
search for in the  
<odbc_proceduresodbc_result>
view the version of this page
Last updated: Thu, 21 Aug 2003

odbc_result_all

(PHP 3>= 3.0.6, PHP 4 )

odbc_result_all -- Print result as HTML table

Description

int odbc_result_all ( resource result_id [, string format])

Returns the number of rows in the result or FALSE on error.

odbc_result_all() will print all rows from a result identifier produced by odbc_exec(). The result is printed in HTML table format. With the optional string argument format, additional overall table formatting can be done.



add a note add a note User Contributed Notes
odbc_result_all
marius at stones dot com
25-Jun-2003 12:21
I've written this little function that functions simirarly to odbc_result_all, but works with MySQL:

/**
 * This function emulates the odbc_result_all function, which will return a HTML table cosisting of
 * the results of an SQL query.
 * Usage: pass a mysql result set to this function, and it will return (not output) a string containing
 * an HTML table
 * Parameters:
 * - $result is your mysql result set (result of a mysql_query() function call)
 * - $tableFeatures is a string containing any HTML TABLE features you would like in the table
 *   (eg. BORDER="0" etc.)
 */
function _mysql_result_all($result, $tableFeatures="") {
  $table .= "<!--Debugging output for SQL query-->\n\n";
  $table .= "<table $tableFeatures>\n\n";
  $noFields = mysql_num_fields($result);
  $table .= "<tr>\n";
  for ($i = 0; $i < $noFields; $i++) {
    $field = mysql_field_name($result, $i);
    $table .= "\t<th>$field</th>\n";
  }
  while ($r = mysql_fetch_row($result)) {
    $table .= "<tr>\n";
    foreach ($r as $kolonne) {
      $table .= "\t<td>$kolonne</td>\n";
    }
    $table .= "</tr>\n";
  }
  $table .= "</table>\n\n";
  $table .= "<!--End debug from SQL query-->\n\n";
  return $table;
}

Enjoy...
cchristianed at netzero dot net
03-Apr-2003 01:31
About the $result reseting array instead of using:
1) odbc_fetch_row($result, 1);
use:
2) odbc_fetch_row($result, 0);

1) will fail because it will not show first record, arrays start with subscript 0.
sanjay dot ghimire at kpmg-infodesign dot com
04-Dec-2002 07:47
I wrote a small function slightly similiar to odbc_record_all, but there you can use format for both table and rows separately, which is not by odbc_record_all. hope it will be useful some how.

--- Sanjay, Germany

Here is code:

odbc_result_all_ex($result, 'Border=0 cellspacing=0 cellpadding=5', "style='FONT-FAMILY:Tahoma; FONT-SIZE:8pt; BORDER-BOTTOM:solid 1pt gree'");

function odbc_result_all_ex($res, $sTable, $sRow)
{
    $cFields = odbc_num_fields($res);
   
    $strTable = "<table $sTable>";
    $strTable .= "<tr>";
    for ($n=1; $n<=$cFields; $n++)
    {
       
        $strTable .= "<td $sRow><b>". str_replace("_", " ", odbc_field_name($res, $n)) . "</b></td>";
   
    }
    $strTable .= "</tr>";
   
    while(odbc_fetch_row($res))
    {
        $strTable .= "<tr>";
            for ($n=1; $n<=$cFields; $n++)
            {
                if (odbc_result($res, $n)=='')
                {
                    $strTable .= "<td $sRow>&nbsp;</td>";
                }
                else
                {
                    $strTable .= "<td $sRow>". odbc_result($res, $n) . "</td>";
                }

            }
        $strTable .= "</tr>";
    }
       
    $strTable .= "</table>";
   
    Print $strTable;
   
}
hwaarl at ctp dot com
27-Jan-2001 01:43
Being a bit more helpful, I did get to see all rows by using the function rather than just the method call.

Doesn't work:
   odbc_result_all($res)
Does work:
   $nr = odbc_result_all($res)
rabbott at calstatela dot edu
16-Aug-2000 07:46
odbc_result_all($result) cycles through
$result. So a subsequent call to odbc_fetch_row($result) will fail.
You must use odbc_fetch_row($result, 1)
to reset $result.  (But when I do that,
I get a crash!)
martin dot vgagern at gmx dot net
26-Mar-2000 04:49
As some people stated in the ODBC overview, some buggy drivers always return the number of rows to be -1. AFAIK the only way to help this situation is to count the rows by calls to odbc_fetch_into or odbc_fetch_row and then build the table yourself.
Cwhite1000 at yahoo dot com
23-Apr-1999 07:39
Here is an example of how to use the form argument"
odbc_result_all($res1, "BGCOLOR='#AAFFAA' border=3 width=30% bordercolordark='#FF0000'");

<odbc_proceduresodbc_result>
 Last updated: Thu, 21 Aug 2003
show source | credits | sitemap | mirror sites 
Copyright © 2001-2003 The PHP Group
All rights reserved.
This mirror generously provided by: http://php.mirrors.ilisys.com.au/
Last updated: Sat 01 Nov 2003 04:13:36 EST EST