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.
Re: Help With Returning Recordset
You could make $result a Global variable so it can be used from another page.
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
}
}