You are on page 1of 2

consulta.

php:

<!DOCTYPE html>
<html >
<head>
<meta charset="UTF-8">
<title>Consulta MySQL- Tutorial 18</title>
</head>
<body>
<?php
$conexion = mysql_connect("localhost", "root", "root");
mysql_select_db("tutorial17", $conexion);
mysql_query("SET NAMES 'utf8'");

$resultado = mysql_query("SELECT DISTINCT `usuario` FROM `tabla` WHERE 1");

?>
<form action="respuesta.php" method="POST">
<select name="usuario">
<?php
while ($row=mysql_fetch_array($resultado))
{
echo "<option>";
echo $row[0];
echo "</option>";
}
mysql_close();
?>
</select><br>
<input type="date" name="fecha" ><br>
<input type="submit" name="Enviar" >
</form>
</body>
</html>

respuesta.php:

<!DOCTYPE html>
<html>
<head>
<title>Respuesta MySQLL - Tutorial 18</title>
<meta charset="UTF-8">
</head>
<body>
<?php
$conexion = mysql_connect("localhost", "root", "root");
mysql_select_db("tutorial17", $conexion);
mysql_query("SET NAMES 'utf8'");

function temperatura_diaria ($usuario,$ano,$mes,$dia) {

$resultado=mysql_query("SELECT UNIX_TIMESTAMP(fecha), mensaje FROM tabla WHERE


year(`fecha`) = '$ano' AND month(`fecha`) = '$mes' AND day(`fecha`) = '$dia' AND
`usuario`= '$usuario' AND `topic`= 'temperatura'");

while ($row=mysql_fetch_array($resultado))
{
echo "[";
echo ($row[0]*1000)-10800000; //le resto 3 horas = 10800000 mill
echo ",";
echo $row[1];
echo "],";
}
}
?>

<div id="container1" style="width: 100%; height: 400px;"></div>

<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>

<script>

You might also like