Need some help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • shakeel
    New Member
    • Aug 2006
    • 5

    #1

    Need some help

    Hi! to all,
    I have some problems using php with ODBC and access database
    i want ot get number of row in a table. code is like
    <?php
    $link=odbc_conn ect("myDSN","", "") or die ("Failed");
    $result=odbc_ex ec($link,"SELEC T * FROM tablename");
    echo odbc_num_rows($ result);
    ?>
    the result of this page is -1

    what cursor type should i use to get number of rows. plz give me an example.
    thanks
  • vssp
    Contributor
    • Jul 2006
    • 268

    #2
    Hi here is the sample code
    === CODE ===
    $db = '\\\\server\\re source\\db.mdb' ;
    $conn = new COM('ADODB.Conn ection');
    $conn->Open("DRIVER={ Driver do Microsoft Access (*.mdb)}; DBQ=$db");
    // Driver do Microsoft Access (*.mdb)
    // must be the name in your odbc drivers, the one you get
    // from the Data Sources (ODBC).
    // In this case, I'm in Mexico but the driver name is in portuguese, thanks Microsoft.
    $sql = 'SELECT username FROM tblUsuarios';
    $res = $conn->Execute($sql );
    while (!$res->EOF)
    {
    print $res->Fields['username']->Value . "
    ";
    $res->MoveNext();
    }
    $res->Close();
    $conn->Close();
    $res = null;
    $conn = null;
    === /CODE ===

    Comment

    • shakeel
      New Member
      • Aug 2006
      • 5

      #3
      thanks VssP
      i want to create a telephone directory and want to display 10 record per page, for that i wanna to know how many records or rows in the table. my problem is how to get number of rows in a table like if a table has 10 rows the odbc_num_rows should return 10 insted of -1, i think this is cursor problem, what cusor type should i use?
      thanks again for your help

      Comment

      Working...