Results 1 to 3 of 3

Thread: Help With Returning Recordset

  1. #1

    Thread Starter
    Member
    Join Date
    Dec 2004
    Posts
    49

    Help With Returning Recordset

    Hi,

    I'm a newbie to PHP. Right now, I'm doing a function that returns a set of records to another php page. My situation is as follows:

    I have a function defined as this.
    PHP Code:
    function executeReader($aQuery) {
    //Connection has been made to the database
    $result mysql_fetch_array($aQuery) ;
    if (!
    $result) {
    echo 
    "Error" ;
    }
    else {
    return 
    $result
    }

    From here, I would return a set of records. For example, my sql query string is "Select * From Customer"

    What I wish to derive is that when i call this function from another file, displayResults.php, I would be able to get all the data from the recordset?

    I know that it's hard to imagine, but i hope someone could help me with it.
    ______________________________________

    Warmest Regards,

    Lex
    ______________________________________



    :|: Don't Mess With The Predator :|:

  2. #2
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697

    Re: Help With Returning Recordset

    You could make $result a Global variable so it can be used from another page.

  3. #3
    Fanatic Member TDQWERTY's Avatar
    Join Date
    Oct 2003
    Location
    Oporto & Leiria, Portugal / Luanda, Angola
    Posts
    972

    Re: Help With Returning Recordset

    Try something like:

    $result = executeReader("Select * From Customer");
    $result can result in 2 diferent values, Boolean (False) or the result of your query.

    To call and get back the results from that function

    PHP Code:
    function executeReader($aQuery) {
    //Connection has been made to the database
    $result mysql_fetch_array($aQuery) ;
    if (!
    $result) {
    echo 
    "Error";
    return 
    false;
    }
    else {
    return 
    $result
    }

    ::Winamp 5.xx id3v2 & modern skin support::
    ::NetCF DataGrid Programatically Scroll Example::
    Don't forget to rate posts from those who helped you solving your problem, clicking on and rating it.

Posting Permissions

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



Click Here to Expand Forum to Full Width