|
-
Oct 2nd, 2005, 01:42 PM
#1
Thread Starter
Member
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 :|:
-
Oct 2nd, 2005, 07:28 PM
#2
Re: Help With Returning Recordset
You could make $result a Global variable so it can be used from another page.
-
Oct 4th, 2005, 08:27 PM
#3
Fanatic Member
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
}
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|