Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    May 2008
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to get total no. of rows in PHP. I'm not using mysql.

    Hi,

    Please tell me how to find the total number of rows fetched my a query. I'm getting the rows from Teradata and not using MySql.

    i tried with the following but in vain..

    //$rows=odbc_num_rows($query);
    //echo $rows;

    //$rows= "SELECT count(*) as result FROM (".$query.")";
    //echo $rows;

    //$num_rows = mysql_num_rows($query);
    //echo $num_rows;

    $totrows=odbc_fetch_row($query);
    echo $totrows;

    //$totrows=ROW_COUNT($query);
    //echo $totrows;

    Please help..

    Thanks,
    RRVARMA

  • #2
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,638
    Thanks
    2
    Thanked 404 Times in 396 Posts
    How are you querying the database?

  • #3
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,980
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    odbc_num_rows should work for you, as long as you are relating to a resource returned from an odbc_exec() call. Thats the strange part of it. Are you sure you are actually executing the query, or are you trying to pass the query as a string to the num_rows call? Another option would be to run a counter in a corelated subquery to count the results being done, but that should not be necessary....

    Edit:
    Beaten to the punch
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •