jramsden
asked on
PHP / ODBC COUNT RECORDS ????
Hi all,
Connecting to a Access Database (Don't ask why), and want to get back a simple SELECT COUNT(*) but it's returning Resource ID #4.
What am I doing wrong.
$query works fine.
Thanks,
Jas.
$odbc = odbc_connect ('leads', '', '') or die( "Could not connect to database at this time. Please try again in 5 minutes." );
$query = odbc_exec($odbc, "SELECT * FROM 0411 ORDER BY Number DESC") or die ( "Error getting data, please try again." );
$total = odbc_exec($odbc, "SELECT COUNT(*) FROM 0411");
echo $total;
Connecting to a Access Database (Don't ask why), and want to get back a simple SELECT COUNT(*) but it's returning Resource ID #4.
What am I doing wrong.
$query works fine.
Thanks,
Jas.
$odbc = odbc_connect ('leads', '', '') or die( "Could not connect to database at this time. Please try again in 5 minutes." );
$query = odbc_exec($odbc, "SELECT * FROM 0411 ORDER BY Number DESC") or die ( "Error getting data, please try again." );
$total = odbc_exec($odbc, "SELECT COUNT(*) FROM 0411");
echo $total;
ASKER
Sorry hernst42,
Does not seem to display anything.
I know the data is there as I can diusplay the whole table.
Jas.
Does not seem to display anything.
I know the data is there as I can diusplay the whole table.
Jas.
What does the following output ??
$odbc = odbc_connect ('leads', '', '') or die( "Could not connect to database at this time. Please try again in 5 minutes." );
$tq = odbc_exec($odbc, "SELECT COUNT(*) FROM 0411");
$total = odbc_fetch_array($tq);
var_dump($total);
$odbc = odbc_connect ('leads', '', '') or die( "Could not connect to database at this time. Please try again in 5 minutes." );
$tq = odbc_exec($odbc, "SELECT COUNT(*) FROM 0411");
$total = odbc_fetch_array($tq);
var_dump($total);
ASKER
I have a access DB that has a unique number, date, time, subject, email and body details.
The page list's all the rows (which it doe's fine) and I need a summary part that show the total rows and that's it.
Your var_dump($total); shows -
array(1) { ["Expr1000"]=> string(3) "595" }
Where 595 is the correct answer.
Jas.
The page list's all the rows (which it doe's fine) and I need a summary part that show the total rows and that's it.
Your var_dump($total); shows -
array(1) { ["Expr1000"]=> string(3) "595" }
Where 595 is the correct answer.
Jas.
then use $total['Expr1000'] to get that value
ASKER
Great.
Works fine.
Is it possible to give a grief explaination for var_dump.
Cheers for your expertise.
Jas.
Works fine.
Is it possible to give a grief explaination for var_dump.
Cheers for your expertise.
Jas.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks.
$tq = odbc_exec($odbc, "SELECT COUNT(*) FROM 0411");
$total = odbc_fetch_array($tq);
echo "Total is :" . $total[0];