I'm not sure I completely understand what you're asking, but taking a

... assuming you're just wanting to work with the data...

... and assuming you're creating a results set from your db query, start
with this code:

$Results = mysql_query($sql, $DBLink);

Within your function, you can specify a global variable:

function ProcessData()
        global $Results;



- or -

You can copy the results to an array and pass that around, like this:

$data = array;
$Results = mysql_query($sql, $DBLink);
while ($Row = fetch_array($Results))
        $data[] = $Row[];


function ProcessData($UserData)
        ... processing ...

-----Original Message-----
From: Leotta, Natalie (NCI/IMS) [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, June 12, 2002 2:00 PM
To: PHP General List
Subject: [PHP] including functions, passing objects I created

I have a line class that I'm using to draw a line graph of up to 5 lines.
Since I query the db for each of those lines (with a # as lineNum), my code
to take everything out of the fetch_arrays is fairly cumbersome.  I use this
code in 4 different programs (the graph, the printable graph, the data
table, and the accessible [D]).  To avoid code duplication, I'd really like
to be able to pass $sql and the 5 lines to a function in a different file,
that all 4 of my programs can use.
I have tried both 
function runSQL ($sql, &$line1, &$line2...) {
function runSQL ($sql, $line1, $line2...) {
    return array ($line1, $line2...);
but both ways timeout.  Is there any way for me to put data into my line
objects from a function?  I know that the include is working because I have
a test function that just prints out "Hello".
I've checked the manual, but it doesn't say anything about having a
user-made object as a param or a return.
Thanks for any info you may have!

Natalie S. Leotta
Information Management Services, Inc.
(301) 680-9770

This message is intended for the sole use of the individual and entity to
whom it is addressed, and may contain information that is privileged,
confidential and exempt from disclosure under applicable law.  If you are
not the intended addressee, nor authorized to receive for the intended
addressee, you are hereby notified that you may not use, copy, disclose or
distribute to anyone the message or any information contained in the
message.  If you have received this message in error, please immediately
advise the sender by reply email and delete the message.  Thank you very

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to