Foros del Web » Programando para Internet » PHP »

Php para actualizar bd mysql

Estas en el tema de Php para actualizar bd mysql en el foro de PHP en Foros del Web. Buenos dias, Hoy vengo con otra dudita no creo que sea muy dificil solo que me encuentro contra el tiempo, necesito en el siguiente codigo ...
  #1 (permalink)  
Antiguo 10/10/2012, 10:37
 
Fecha de Ingreso: septiembre-2012
Ubicación: Norte de Santander
Mensajes: 127
Antigüedad: 11 años, 7 meses
Puntos: 1
Pregunta Php para actualizar bd mysql

Buenos dias,
Hoy vengo con otra dudita no creo que sea muy dificil solo que me encuentro contra el tiempo, necesito en el siguiente codigo lanzar un contador para los registros que se han de actualizar al ejecutar el script y tambien un mensaje para la sentencia mysql de actualizar que me diga algo como Actualizado con exito.....
Codigo:
Código PHP:
<?php
ini_set
('max_execution_time'300);
//Exportar datos de php a Excel
header("Content-Type: application/vnd.ms-excel");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("content-disposition: attachment;filename=Reporteactualizados.xls");
include(
"../../conexiones/conexion.php");

$rt mysql_query("SELECT * FROM TABLA");
$ntotal mysql_num_rows($rt);
$rs mysql_query("SELECT * FROM TABLA WHERE nmatricula = 0");
$nregcero mysql_num_rows($rs);
    while(
$registro mysql_fetch_assoc($rs)){
        
$rf mysql_query("SELECT * FROM BASEDEDATOS.TABLA WHERE numid=".$registro['cedula']." and estmatricula = 'MA' and fecmatricula >= '20120801'");
        while(
$fila mysql_fetch_assoc($rf)){
            if(
$fila['organizacion'] != 02){
                
$q="UPDATE TABLA SET 
                    nmatricula = '"
.$fila['matricula']."', 
                    fecha = '"
.$fila['fecmatricula']."' 
                    WHERE cedula = '"
.$fila['numid']."'
                    "
;
                    
mysql_query($q,$link) or die (mysql_error());
            }
        }
    }
$nregact$ntotal-$nregcero;
?>
<html>
<head>
<title></title>
</head>
<table border="1">
<caption>REPORTE DE ACTUALIZACION DE MATRICULAS</caption>
<tr><td>REGISTROS TOTALES EN ACTA DE FORMALIZACION</td><td><?php echo $ntotal?></td></tr>
<tr><td>REGISTROS CON MATRICULAS</td><td><?php echo $nregact?></td></tr>
<tr><td>REGISTROS CON MATRICULAS EN CERO</td><td><?php echo $nregcero?></td></tr>
<tr><td>MATRICULAS ACTUALIZADAS</td><td></td></tr>
</table>
</html>
  #2 (permalink)  
Antiguo 10/10/2012, 12:11
Avatar de Triby
Mod on free time
 
Fecha de Ingreso: agosto-2008
Ubicación: $MX->Gto['León'];
Mensajes: 10.106
Antigüedad: 15 años, 8 meses
Puntos: 2237
Respuesta: Php para actualizar bd mysql

Como ya enviaste encabezados, el código HTML se adjuntará al archivo Reporteactualizados.xls

No puedes combinar descarga de archivos y HTML en la misma petición.
__________________
- León, Guanajuato
- GV-Foto
  #3 (permalink)  
Antiguo 11/10/2012, 09:28
 
Fecha de Ingreso: septiembre-2012
Ubicación: Norte de Santander
Mensajes: 127
Antigüedad: 11 años, 7 meses
Puntos: 1
Respuesta: Php para actualizar bd mysql

Gracias Triby ya se que lo del mensaje no se puede pero como hago lo del contador...
Ahh por cierto mi codigo est asi:
Código PHP:
<?php
ini_set
('max_execution_time'300);
//Exportar datos de php a Excel
header("Content-Type: application/vnd.ms-excel");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("content-disposition: attachment;filename=Reportes.xls");
include(
"../../conexiones/conexion.php");

$rt mysql_query("SELECT * FROM tabla");
$ntotal mysql_num_rows($rt);
$rs mysql_query("SELECT * FROM tabla WHERE nmatricula = 0");
    while(
$registro mysql_fetch_assoc($rs)){
        require(
"../../conexiones/conexionSii.php");
        
$rf mysql_query("SELECT * FROM tabla WHERE numid=".$registro['cedula']." and estmatricula = 'MA' and fecmatricula >= '20120801'");
        while(
$fila mysql_fetch_assoc($rf)){
            if(
$fila['organizacion'] != 02){
            require(
"../../conexiones/conexion.php");
                
$q="UPDATE tabla SET 
                    nmatricula = '"
.$fila['matricula']."', 
                    fecha = '"
.$fila['fecmatricula']."' 
                    WHERE cedula = '"
.$fila['numid']."'
                    "
;
                    
mysql_query($q,$link) or die (mysql_error());
            }
        }
    }
require(
"../../conexiones/conexion.php");
$rs mysql_query("SELECT * FROM tabla WHERE nmatricula = 0");
$nregcero mysql_num_rows($rs);
$nregmat$ntotal-$nregcero;
?>
<html>
<head>
<title></title>
</head>
<table border="1">
<tr><td colspan="2"><b>REPORTE DE ACTUALIZACION DE MATRICULAS</b></tr>
<tr><td><b>REGISTROS TOTALES EN ACTA DE FORMALIZACION</b></td><td><?php echo $ntotal?></td></tr>
<tr><td><b>REGISTROS CON MATRICULAS</b></td><td><?php echo $nregmat?></td></tr>
<tr><td><b>REGISTROS CON MATRICULAS EN CERO</b></td><td><?php echo $nregcero?></td></tr>
<tr><td><b>MATRICULAS ACTUALIZADAS</b></td><td></td></tr>
</table>
</html>
Es completamente funcional pero no puedo hacer un contador ya intente con mysql_affected_rows pero no me funciona no se donde lo podria colocar para que funcione

Última edición por karma274; 11/10/2012 a las 09:44

Etiquetas: bd, html, mysql, registro, tabla
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 12:17.