Ver Mensaje Individual
  #1 (permalink)  
Antiguo 22/11/2011, 21:19
migbreu
 
Fecha de Ingreso: noviembre-2011
Mensajes: 2
Antigüedad: 12 años, 5 meses
Puntos: 0
¿Como puedo guardar los registros de mi base de dato en un documento .txt?

¿Como puedo guardar los registros de mi base de dato en un documento .txt?
si yo extraigo los registros de una tabla en una pagina php quiero guardarlos en un documento txt como podría hacerlo? claro si agrego un nuevo registro y lo visualiza en la pagina php también se actualiza el documento txt.
este es el código que tengo para visualizar el pagina php...
<?php
//1. abrir la conecxion..
$idc = mysql_connect("localhost","root","");
if (!$idc) // si no conecta
die("Error Al Abrir La Conecxion.");
//2. seleccionar la BD
if(!mysql_select_db("sistema_de_logs",…
// si no selecciona la bd
die("Error Al Seleccionar La BD");
//3.crear la sentencia a ejecutar
$sql = "SELECT * FROM formulario";
$res = mysql_query($sql,$idc);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-…
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Documento sin título</title>
</head>
<body bgcolor="#999999">

<table width="422" border="0" align="center">
<tr>
<td width="290" align="center"><h3><strong>Sistema de logs.</strong></h3></td>
</tr>
</table>
<table width="940" border="1">
<tr align="center">
<td width="78" valign="middle"><strong>Fecha Del Reporte</strong></td>
<td width="59"><strong>Hora Del Repote </strong></td>
<td width="80"><strong>Asociado Que Repota</strong></td>
<td width="96"><strong>Departamento</strong>…
<td width="115"><strong>Descripcion De Fallas</strong></td>
<td width="113"><strong>Notas</strong></td>
<td width="77"><strong>Fecha De Reparacion</strong></td>
<td width="80"><p><strong>Fue </strong><strong>Solucionado</strong></p…
<td width="72"><strong>Prioridad</strong></t…
</tr>
<?php
//se obtiene el total de resgistros..
$total = mysql_num_rows($res);
for($i = 0; $i<$total;$i++){
$fila = mysql_fetch_array($res);
?>
<tr align="center">
<td><?php echo $fila['fecha_reporte']; ?></td>
<td><?php echo $fila['hora_reporte']; ?></td>
<td><?php echo $fila['asociado_reporte']; ?></td>
<td><?php echo $fila['departamento']; ?></td>
<td><?php echo $fila['descripcion_falla']; ?></td>
<td><?php echo $fila['notas']; ?></td>
<td width="77"><?php
if( $fila['fecha_reparacion']==000-00-00)
echo "";
else
echo $fila['fecha_reparacion'];
?></td>
<td><?php echo $fila['solucionado']; ?></td>
<td width="77" <?php
if( $fila['prioridad']=="Si"){ ?>
bgcolor=red><span style="color:ffffff"><b> <?php echo $fila['prioridad']; ?></b></span>
<?PHP }else{?>
bgcolor="#999999"><?php echo $fila['prioridad'];?>
<?PHP }?></td>
</tr>
<?php } ?>
</table>
</body></html>
<?php
//4. cerrar la conecxion
mysql_close($idc);
?>