× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Probably a little over-engineered, but this works for me!


<?php

function Connect() {
// Standard DB connection to DB2...

$conn = "*LOCAL"; $name = ""; $pwd = "";
$i5link = db2_connect($conn, $name, $pwd);
if (!$i5link)
echo 'Connection failed: '.db2_stmt_error().' :
'.db2_stmt_errormsg();
return $i5link;
}

function getRowCount($i5link, $table) {


$sql = "SELECT count(*) as NUMROWS from $table";
$stmt = db2_exec($i5link,$sql)
or die("Failed
query:".db2_stmt_error().":".db2_stmt_errormsg());
$res = db2_fetch_assoc($stmt);

return ($res);
}

$connection = Connect();

$table = 'sysibm.systbltype';
$rows_array = getRowCount($connection, $table);
$rows = $rows_array['NUMROWS'];

echo "The number of rows in table $table is $rows";

?>



Regards,

Mike

mike.p@xxxxxxxx Cell: (408)679-1011 Office: (815)722-3454

Zend Server for IBM i Beta avilable at
http://www.zend.com/en/products/server/zend-server-5-new-ibmi



-----Original Message-----
From: web400-bounces@xxxxxxxxxxxx [mailto:web400-bounces@xxxxxxxxxxxx]
On Behalf Of Michael Ryan
Sent: Tuesday, May 18, 2010 1:45 PM
To: Web Enabling the AS400 / iSeries
Subject: [WEB400] PHP count rows

Seems simple...I want a count of the number of rows in a table, put that
count into a variable, and then display that variable. Anyone have a
snippet? Thanks...

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.