prova così
codice:
$result = mysql_query("SELECT * FROM tabella");
while($data = mysql_fetch_row($result) {
$array[k++]=$data;
...codice..
}
dovresti avere in $array il risultato della query