if(mysql_num_rows($registros) > 0){ while ($reg=mysql_fetch_array($registros)){ //imprime registros } }else //mensaje de error }