problem with array returning.
Posted: Thu Jun 29, 2006 4:18 am
Code: Select all
function sorted_votes($myaverage)
{
$myarray = array();
$uarray = array();
$i = 0;
$j = 0;
$res = mysql_query("select * from votes") or die(mysql_error());
while($row = mysql_fetch_object($res))
{
$mycnt = (($row -> cnt)/$myaverage);
$myarray[$i] = $mycnt;
$i = $i + 1;
}
sort($myarray);
foreach ($myarray as $key => $val)
{
$uarray[$j] = $val;
}
return $uarray;
}
$myaverage = total();
$myarr = array();
$myarr = sorted_votes($myaverage);
echo $myarr[2]; // this is not giving me the output.when is try sorted_votes() its works fine but after returning it dont' show the result.
any help?
thanks.