Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit d5f0375

Browse files
author
peter
committedSep 11, 2018
lezen sensor data, en vervolgens opslaan in database
0 parents  commit d5f0375

File tree

5 files changed

+115
-0
lines changed

5 files changed

+115
-0
lines changed
 

‎add_data.php

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
// Connect to MySQL
3+
include("dbconnect.php");
4+
5+
// Prepare the SQL statement
6+
$SQL = "INSERT INTO orta1.temperature (sensor ,celsius) VALUES ('".$_GET["serial"]."', '".$_GET["temperature"]."')";
7+
8+
// Execute SQL statement
9+
mysql_query($SQL);
10+
11+
// Go to the review_data.php (optional)
12+
header("Location: review_data.php");
13+

‎dbconnect.php

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
$MyUsername = "root"; // mysql gebruikersnaam
3+
$MyPassword = "welkom"; // mysql wachtwoord
4+
$MyHostname = "localhost"; // dit is meestal "localhost" tenzij mysql op een andere server staat
5+
6+
$dbh = mysql_pconnect($MyHostname , $MyUsername, $MyPassword);
7+
$selected = mysql_select_db("orta1",$dbh);
8+
9+
?>
10+
11+
12+
13+
14+

‎nbproject/project.properties

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
include.path=${php.global.include.path}
2+
php.version=PHP_56
3+
source.encoding=UTF-8
4+
src.dir=.
5+
tags.asp=false
6+
tags.short=false
7+
web.root=.

‎nbproject/project.xml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://www.netbeans.org/ns/project/1">
3+
<type>org.netbeans.modules.php.project</type>
4+
<configuration>
5+
<data xmlns="http://www.netbeans.org/ns/php-project/1">
6+
<name>WebOrta</name>
7+
</data>
8+
</configuration>
9+
</project>

‎review_data.php

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<?php
2+
// Start MySQL Verbinding
3+
include('dbconnect.php');
4+
?>
5+
6+
<html>
7+
<head>
8+
<title>Arduino Temperature Log</title>
9+
<style type="text/css">
10+
.table_titles, .table_cells_odd, .table_cells_even {
11+
padding-right: 20px;
12+
padding-left: 20px;
13+
color: #000;
14+
}
15+
.table_titles {
16+
color: #fff;
17+
background-color: #3300ff;
18+
}
19+
.table_cells_odd {
20+
background-color: #3399ff;
21+
}
22+
.table_cells_even {
23+
background-color: #33ccff;
24+
}
25+
table {
26+
border: 2px solid #333;
27+
}
28+
body { font-family: "Trebuchet MS", Arial; }
29+
</style>
30+
</head>
31+
32+
<body>
33+
<h1>Arduino Temperature Log</h1>
34+
<table border="0" cellspacing="0" cellpadding="4">
35+
<tr>
36+
<td class="table_titles">ID</td>
37+
<td class="table_titles">Date and Time</td>
38+
<td class="table_titles">Sensor Serial</td>
39+
<td class="table_titles">Temperature in Celsius</td>
40+
</tr>
41+
<?php
42+
// Retrieve all records and display them
43+
$result = mysql_query("SELECT * FROM temperature ORDER BY id ASC");
44+
45+
// Used for row color toggle
46+
$oddrow = true;
47+
48+
// process every record
49+
while( $row = mysql_fetch_array($result) )
50+
{
51+
if ($oddrow)
52+
{
53+
$css_class=' class="table_cells_odd"';
54+
}
55+
else
56+
{
57+
$css_class=' class="table_cells_even"';
58+
}
59+
60+
$oddrow = !$oddrow;
61+
62+
echo '<tr>';
63+
echo ' <td'.$css_class.'>'.$row["id"].'</td>';
64+
echo ' <td'.$css_class.'>'.$row["event"].'</td>';
65+
echo ' <td'.$css_class.'>'.$row["sensor"].'</td>';
66+
echo ' <td'.$css_class.'>'.$row["celsius"].'</td>';
67+
echo '</tr>';
68+
}
69+
?>
70+
</table>
71+
</body>
72+
</html>

0 commit comments

Comments
 (0)
Please sign in to comment.