replace while mysql_fetch_assoc with foreach loop