MikeAuz1979
Programmer
Hi,
Using PHP,Apache and MS-SQL2000 I'm trying to get the required sql output and a counter at the top that says something like '100 out of 15000 records returned' I have the below code thanks to and a bit of legwork but when I run this I get the result 100 out of 1 records returned. For some reason the variable $TC is only getting populated as 1 rather than the true count of the table.
NB: I'm working on the idea that I can re-use the ado connection hence the $rs->close();
Anyone have any ideas?
Thanks for any help
Mike
Using PHP,Apache and MS-SQL2000 I'm trying to get the required sql output and a counter at the top that says something like '100 out of 15000 records returned' I have the below code thanks to and a bit of legwork but when I run this I get the result 100 out of 1 records returned. For some reason the variable $TC is only getting populated as 1 rather than the true count of the table.
NB: I'm working on the idea that I can re-use the ado connection hence the $rs->close();
Anyone have any ideas?
Thanks for any help
Mike
Code:
<?php
include('../adodb5/adodb.inc.php');
$db =& ADONewConnection('odbc_mssql');
$db->Connect('Driver={SQL Server};Server=localhost;Database=gb32_Tims', 'sa', 'potty');
//Get total no of rows in table
$sql = "Select Count(*) from account";
$rs = $db->execute($sql);
$TC = $rs->RecordCount();
$rs->close();
//Get limited results and row count of returned results
$sql = "Select acct_i from account";
$rs = $db->SelectLimit($sql,20,100); // Select x rows, starting at row y
print "[" . $rs->RecordCount() . " Out of " . $TC . " Records Returned] <BR>"; // Display number of rows returned
while (!$rs->EOF) {
print $rs->fields[0].'<BR>';
$rs->MoveNext(); // Moves to the next row
} // end while
php?>