Modificación Paginas PHP:
Para culminar el proyecto fue necesario realizar algunas modificaciones a la Base de Datos, con el fin de mejorar la inserción en la Información se realizó lo siguiente:
Se usarion dos Insert Into en vez de uno así: sensor.php
<?php
$pir = $_GET['pir'];
$tem = $_GET['tem'];
$dia = date('d');
$mes = date('m');
$anio = date('Y');
$hora = date('h');
$minuto = date('i');
$segundo = date('s');
$conexion = mysql_connect("10.245.74.55", "php", "123");
mysql_select_db("alarma",$conexion);
$sql1 = "INSERT INTO `datos_alar`(`id`, `dia`, `mes`, `anio`, `hora`, `minuto`, `segundo`, `pir`) VALUES
(NULL,'$dia','$mes','$anio','$hora','$minuto','$segundo','$pir')";
$res1 = mysql_query($sql1, $conexion) or die ("Error en la consulta");
$sql2 = "INSERT INTO `sensor_tem`(`id`, `dia`, `mes`, `anio`, `hora`, `minuto`, `segundo`, `tem`) VALUES
(NULL,'$dia','$mes','$anio','$hora','$minuto','$segundo','$tem')";
$res2 = mysql_query($sql2, $conexion) or die ("Error en la consulta");
?>
mostrar.php:
Se utilizaron en una misma pagina las dos conexiones a una misma base de datos, pero a tablas diferentes.
<?php
$conexion = mysql_connect("10.245.74.55", "php", "123");
mysql_select_db("alarma",$conexion);
$sql1 = "SELECT * FROM `datos_alar`";
$res1 = mysql_query($sql1, $conexion) or die ("Error en la consulta");
$sql2 = "SELECT * FROM `sensor_tem`";
$res2 = mysql_query($sql2, $conexion) or die ("Error en la consulta");
$total1 = mysql_num_rows($res1);
$total2 = mysql_num_rows($res2);
if ($total1 > 0)
{
echo "<table border = 1 align = left>"
."<tr>\n<td colspan=8 width=159 align=center>Datos Hora y Fecha para Alarma</td></tr>\n"
."<tr>\n"
."<th>id</th>\n"
."<th>Dia</th>\n"
."<th>Mes</th>\n"
."<th>Anio</th>\n"
."<th>Hora</th>\n"
."<th>Minuto</th>\n"
."<th>Segundo</th>\n"
."<th>pir</th>\n"
."</tr>\n"
."</div>";
while($reg = mysql_fetch_array($res1))
{
print "<td>".$reg['id']."</td>";
print "<td>".$reg['dia']."</td>";
print "<td>".$reg['mes']."</td>";
print "<td>".$reg['anio']."</td>";
print "<td>".$reg['hora']."</td>";
print "<td>".$reg['minuto']."</td>";
print "<td>".$reg['segundo']."</td>";
print "<td>".$reg['pir']."</td>";
print "</tr>";
}
}
if ($total2 > 0)
{
echo "<table border = 1 align = right>"
."<tr>\n<td colspan=8 width=159 align=center>Datos Hora Fecha y Temperatura para Sensor</td></tr>\n"
."<tr>\n"
."<th>id</th>\n"
."<th>Dia</th>\n"
."<th>Mes</th>\n"
."<th>Anio</th>\n"
."<th>Hora</th>\n"
."<th>Minuto</th>\n"
."<th>Segundo</th>\n"
."<th>tem</th>\n"
."</tr>\n"
."</div>";
while($reg = mysql_fetch_array($res2))
{
print "<td>".$reg['id']."</td>";
print "<td>".$reg['dia']."</td>";
print "<td>".$reg['mes']."</td>";
print "<td>".$reg['anio']."</td>";
print "<td>".$reg['hora']."</td>";
print "<td>".$reg['minuto']."</td>";
print "<td>".$reg['segundo']."</td>";
print "<td>".$reg['tem']."</td>";
print "</tr>";
}
}
?>
<html>
<head>
<title>mostrar.php</title>
<script language="JavaScript">
function mueveReloj(){
momentoActual = new Date()
hora = momentoActual.getHours()
minuto = momentoActual.getMinutes()
segundo = momentoActual.getSeconds()
str_segundo = new String (segundo)
if (str_segundo.length == 1)
segundo = "0" + segundo
str_minuto = new String (minuto)
if (str_minuto.length == 1)
minuto = "0" + minuto
str_hora = new String (hora)
if (str_hora.length == 1)
hora = "0" + hora
horaImprimible = hora + " : " + minuto + " : " + segundo
document.form_reloj.reloj.value = horaImprimible
setTimeout("mueveReloj()",1000)
}
</script>
</head>
<body onload="mueveReloj()">
<form name="form_reloj">
<input type="text" name="reloj" size="113" style="background-color : Black; color : White; font-family : Verdana, Arial, Helvetica; font-size : 8pt; text-align : center;" onfocus="window.document.form_reloj.reloj.blur()">
</form>
</body>
</html>