Wrox Programmer Forums
|
PHP Databases Using PHP in conjunction with databases. PHP questions not specific to databases should be directed to one of the other PHP forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 27th, 2004, 04:10 AM
Authorized User
 
Join Date: Aug 2003
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to spraveens
Default EOF in ODBC

Hi
    I am using PHP with ODBC to connect to Database, I want to print a "No record Found" Message if there is no records found after connecting to the database and opening the recordset. How do I do it??

Praveen.;)

 
Old March 28th, 2004, 07:48 PM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

Hi,

Use the odbc_num_rows() function..

$result = odbc_exec($connection, $query);
$row_count = odbc_num_rows($result);

if ($row_count == 0)
{
    echo "No records found.";
}

See:
http://www.php.net/odbc_num_rows

ODBC functions:
http://www.php.net/odbc

hth,
: )
Rich

::::::::::::::::::::::::::::::::::::::::::
The Spicy Peanut Project
http://www.spicypeanut.net
::::::::::::::::::::::::::::::::::::::::::
 
Old March 28th, 2004, 11:43 PM
Authorized User
 
Join Date: Aug 2003
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to spraveens
Default

Hi

     I am getting '-1' as a result of using odbc_num_rows ,I am using PHP with MS access over DSN connection through ODBC.How do I get the number of records?

Thanks
Praveen.
 
Old March 29th, 2004, 12:17 AM
Authorized User
 
Join Date: Aug 2003
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to spraveens
Default

Hi

     I figured out another way to solve a problem using a counter and
odbc_fetch_row.


while (odbc_fetch_row($result_count))
{
   $count++;
}

echo "Title";

if ($count)
{
   echo "Total: <b>$count</b>.";
}
else
{
   echo "No Records Found.";
}

Thank You

Praveen






Similar Threads
Thread Thread Starter Forum Replies Last Post
EOF stealthdevil Access VBA 2 December 21st, 2006 12:41 PM
ODBC - insert on a linked field - [microsoft][ODBC chimp MySQL 0 April 7th, 2005 04:44 AM
HELP WITH EOF chiraagb Classic ASP Databases 12 May 6th, 2004 04:51 AM
While not EOF goplayoutside VB.NET 2002/2003 Basics 3 April 22nd, 2004 04:14 PM
eof new BOOK: Beginning Visual C++ 6 0 October 9th, 2003 07:33 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.