Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2003
    Location
    Ohio/Chicago
    Posts
    75

    Unanswered: any rows in recordset

    PHP Code:
    $strSQL "select * from [post_received] where requestNumber='$D1'";
    $rsD1odbc_exec$conn$strSQL); 
    what do i use to check to see if any values were returned? Everything i've tried so far hasn't worked.

  2. #2
    Join Date
    Sep 2003
    Location
    Wisconsin, USA
    Posts
    34

    odbc

    If your ODBC driver supports it, you can do:
    $numrows = odbc_num_rows($rsD1);

    However, many ODBC drivers do not return information for how many rows were in the recordset. Thus, although PHP supports it, many ODBC drivers will return -1;

    I'm not sure what drivers do and don't support this. I definitely know that the Microsoft JET driver does not.


    As an alternate, you can do an SQL COUNT() on your data.
    Such as:
    $strSQL = "SELECT COUNT(requestNumber) as theCount FROM [post_received] WHERE requestNumber = '$D1'";
    $rsCount = odbc_exec($conn, $strSQL);
    $rsD1Count = (int)odbc_result($rsCount, 'theCount');


    from there do a if($rsD1Count > 0) {}

Posting Permissions

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