I made a function that connects to a databe executes a query and gets the result of the mysql_fetch_array function than returns the array. like this:
function connect($query,$db)
{
connects to mysql
selects db
executes query
returns results with mysql_fecth_array
}
before using this function I used to write every line of code for every query then to access to the data i used the do..while cycle
like this:
connects to mysql
selects db
executes query
do
{
echo $array["name"];
echo $array["age"];
}while ($array = mysql_fetch_array($result)
but using the function I can't do that.
is there any alternative to show the values from the array using something like
begin cycle
$array["name"]
$array["age"]
end cycle
thanks
function connect($query,$db)
{
connects to mysql
selects db
executes query
returns results with mysql_fecth_array
}
before using this function I used to write every line of code for every query then to access to the data i used the do..while cycle
like this:
connects to mysql
selects db
executes query
do
{
echo $array["name"];
echo $array["age"];
}while ($array = mysql_fetch_array($result)
but using the function I can't do that.
is there any alternative to show the values from the array using something like
begin cycle
$array["name"]
$array["age"]
end cycle
thanks