Results 1 to 2 of 2

Thread: Simple Query

  1. #1
    Join Date
    Jan 2004
    Posts
    1

    Unanswered: Simple Query

    I am looking for a simple PHP script that will connect to an MS Access DB on 1 website, and display some information in a block on the other.

    Heres the situation. I have an event registration page hosted on 1 website using IIS and using an Access database. I would like the be able to query the Access DB and count the number of users signed up and display this information on the main website.

    Here is what I have now, but it displays all the fields, I just want a total count of them.

    PHP Code:
    $conn = new COM("ADODB.Connection") or die("Cannot start ADO"); 

    // Microsoft Access connection string.
    $conn->Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=C:\\inetpub\\wwwroot\\mydb.mdb");

    // SQL statement to build recordset.
    $rs $conn->Execute("SELECT ordernumber FROM members");
    echo 
    "<p>Below is a list of values in the LAN.MDB database, MEMBERS table, ORDERNUMBER field.</p>";

    // Display all the values in the records set
    while (!$rs->EOF) { 
        
    $fv $rs->Fields("ordernumber");
        echo 
    "Value: ".$fv->value."<br>";
        
    $rs->MoveNext();

    $rs->Close(); 
    Any help would be great,
    Thanks.
    Last edited by rhs98; 01-23-04 at 11:35.

  2. #2
    Join Date
    Feb 2002
    Location
    San Francisco, CA
    Posts
    441
    Please use [ php ] some code [ / php ] tags in future.

    PHP Code:
    $conn = new COM("ADODB.Connection") or die("Cannot start ADO"); 

    // Microsoft Access connection string.
    $conn->Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=C:\\inetpub\\wwwroot\\mydb.mdb");

    // SQL statement to build recordset.
    $rs $conn->Execute("SELECT count(*) as cnt FROM members");


    echo 
    $rs->Fields("cnt");
    $rs->Close(); 

Posting Permissions

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