while loop fetch database records automatically
by Prakash[ Edit ] 2013-01-28 14:32:59
In while loop we can fecth database rows as an arry recursively
function fetchArray(){
$qry = "select name,age from employee";
$res = mysql_query($qry);
while($row[]=@mysql_fetch_array($res));
$row = @array_filter($row);
}
We can now use :
$employee_array = fetchArray();
foreach($employee_array as $employee){
echo $employee[0]['name'].' : '.$employee[0]['age'].'
';
}