while loop fetch database records automatically

by Prakash 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'].'
';
}

Tagged in:

1196
like
0
dislike
0
mail
flag

You must LOGIN to add comments