Aquí otro ejemplo: Código PHP:
<?php
$conexion = mysql_connect("localhost", "usuario", "clave");
mysql_select_db("BD", $conexion);
$queEmp = "SELECT * FROM tabla_users ORDER BY username ASC";
$resEmp = mysql_query($queEmp, $conexion) or die(mysql_error());
$totEmp = mysql_num_rows($resEmp);
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>LISTA DE Mails</title>
<style type="text/css">
<!--
body {
font-family: "Trebuchet MS", Tahoma, Verdana;
font-size: 12px;
font-weight: normal;
color: #666666;
text-decoration: none;
padding: 20px;
}
h4 {
color: #CC0000;
}
-->
</style>
</head>
<body>
<h4>Lista de Email</h4>
<?php
if ($totEmp> 0) {
while ($rowEmp = mysql_fetch_assoc($resEmp)) {
echo $rowEmp['email_2'].",<br>";
}
}
?>
</body>
</html>
Es algo que uso para sacar direcciones de correo de mis bases de datos.
Espero que te sea útil.
Saludos!