re_escribir dato en un campo de tabla
Publicado por luquint (14 intervenciones) el 14/04/2020 23:40:18
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// ESTE ES EL CODIGO DE LA SOLICITUD HECHA ANTERIORMENTE
<head> <LINK REL=StyleSheet HREF="miestilo.css"> </head>
<body>
<!--<table border="0" style="width:100%" style="background-color:blue" >
<tr>
<td>
<fieldset>-->
<?php
include 'Conexion.php';
$conexion = mysql_connect('localhost','root','' );
mysql_select_db('registro',$conexion) or die ("Error: No conexión");
echo " OK";
//Recibe dato, de insertar en la tabla historial desde la tabla usuarios
//------------------------------------------------------------------------------------------------------------
//RECIBE EL DATO A SOLICITAR, HACE LA CONSULTA A LA TABLA DE --USUARIOS--, SI EXCISTE COPIA ESA INFORMACION EN OTRA TABLA LLAMADA -- HISTORIAL-- Y ME MUESTRA LA INFORMACION DE ESE USUARIO
$dato = $_POST['identidad'];
$result = mysql_query("SELECT * FROM usuario WHERE identidad = $dato");
mysql_query("INSERT INTO historial(identidad, nombres, programa, codigo, correo)
SELECT * FROM usuario WHERE identidad = '$dato'") or die ("Problemas en el INSERT ".mysql_error());
if ($row = @mysql_fetch_array($result))
{
// Hace ele ncabiezado de la tabla
echo "<table border = '0001'> \n";
echo "<tr><td>identidad</td>
<td>Nombres</td>
<td>Programa</td>
<td>Codigo</td>
<td>Correo</td>
</tr> \n";
// Hace la tabla con los datos solicitados
do {
echo"<tr><td>".$row['identidad']
."<td>" .$row['nombres']
."<td>" .$row['programa']
."<td>" .$row['codigo']
."<td>" .$row['correo']
."</td></tr> \n";
$pro= $row['codigo'] ; // me muestra el codigo del usuario seleccionado
$nombre=$row['programa'];
} while ($row = @mysql_fetch_array($resul));
echo "</table> \n";
mysql_close($conexion);
}
//Para sumar la tabla total registros
require'Conexion.php';
//-------------------------------------------------------------------------------------------------------
// ACA HACE EL CONTEO A LA TABLA --HISTORIAL--, LA SUMA DE USUARIOS COPIADOS EN ESA TABLA -- HISTORIAL--
$consulta= mysql_query("SELECT COUNT(*) as refe from historial ");
$result= mysql_fetch_assoc($consulta);
echo "Usuarios registrados: " .$result['refe']; //muestra el conteo de la tabla copia total registrados
$total= $result['refe'];
echo "<br>";
//--------------------------------------------------------------------------------------------------------------------
// ACA HACE EL CONTEO DE USUARIOS POR PROGRAMA DE ESA TABLA -- HISTORIAL--
//Cuenta usuarios por registro de cada programa
$consul= mysql_query("SELECT COUNT(*) as programas from historial WHERE codigo = $pro ");
$res= mysql_fetch_assoc($consul);
echo "Usuarios Registrados del Programa: " .$res['programas'];
$totaluser= $res['programas'];
echo "<br>";
//------------------------------------------------------------------------------------------------------------------------------
// CLASIFICO EL CODIGO DE CADA PROGRAMA DE UN TATOA DE 10 NUMEROS QUE LO CONFORMAN
//-------- me da el codigo del programa variable $resu y la carga en la tabla
$resu=substr("$pro", 2, 2); // Los caracteres de la posicion de la cadena y longitud
echo "Codigo Programa: $resu";
//-------------------------------------------------------------------------------------------------------------------------------
// LA SIGUIENTE TABLA -- ESTADITICA-- QUE ES EN LA QUE QUIERO MOSTRAR EL RESULTADO TOTAL POR PROGRAMA, DE USUARIOS INGRESADOS , COMO CADA VEZ QUE EL USUARIO SE REGISTRA, HACE UNA COPIA Y UN CONTEO DE ESA TABLA DEBE INGRESAR EL ULIMO RESULTADO SIN QUE ME DIGA REGISTRO DUPLICADO, ES LA PARTE QUE NO HE PODIDO RESLVER YA QUE EN EL DIA SE PUDE ESTAR REGISTRANDO DE UN MISMO PROGRAMA VARIOS USUARIOS Y SOLO QUIERO ESE DATO PARA ESE PROGRAMA(SON 8 PROGRAMAS). GRACIAS ESTARE PENDIENTE
mysql_query("INSERT INTO estadistica(codigo,nombre, ingresos)VALUES($resu, 'cn', $totaluser )");
Valora esta pregunta


0