crear html
| From: | Edgardo Rossetto | Date: | Mon, 26 Mar 2001 00:40:58 +0000 |
| Subject: | crear html | ||
| Groups: | php.general.es | ||
| Request: | Send a blank email to general-es+get-8359@lists.php.net to get a copy of this message | ||
Hola Lista:
Necesito crear archivos .html en base a consultas a mysql, esto lo hago para
optimizar el tráfico y el gasto de CPU del server, en difinitiva para no
hacer una consulta a MySQL cada vez que un usuario visite mi sitio, por
ejemplo:
while($fila=mysql_fetch_array($sql)) {
$letra=$fila[letra];
$dir=minuscula($letra);
$fp = fopen("/htdocs/public_html/home/$dir/index.html", "w");
fwrite($fp, "
<html>
<head>
<title>LetrasOnline > $letra</title>
</head>
<body>
<table cellpadding=0 cellspacing=0 border=0 width=90% align=center>
<tr>
<td colspan=2 width=100%><a href=/><img src=/images/new_arrow.gif
border=0 align=absmiddle></a> <font size=4><b><a href=/>Inicio</a>
>
$letra</b></font></td>
</tr>
<tr>
<td colspan=2 width=100%><hr color=#0000ff noshade size=1></td>
</tr>
<tr>
<td width=50%><ul></ul></td>
</tr>
</table>
</body>
</html>");
fclose($fp);
}
De esta forma hago los htmls, pero el problema me surge cuando quiero crear
archivos con esta consulta:
$query = mysql_query("SELECT * FROM artistas WHERE letra='A' ORDER BY
nombre");
$i=0;
while($row = mysql_fetch_array($query)) {
$num=mysql_num_rows($query) / 2;
if ($i >= $num) { echo"</ul></td><td width=50%
valign=top><ul>"; $i=0; }
echo"<li><a
href=/home.php?artista=$row[id]>$row[nombre]</a></li>";
$i++;
}
Realmente no se me ocurre ninguna forma, no si por donde empezar para
transformar el while a un html normal.
Alguna sugerencia?
Saludos
Edgardo Rossetto