How it works...

The show_data_lite.php file shall display the temperature data that has been stored within the SQLite database (either from the ADC samples or local data sources).

The show_data_lite.php file consists of standard HTML code, as well as a special PHP code section. The HTML code sets ACD Data as the title on the head section of the page and uses the following command to make the page automatically reload every 10 seconds:

<meta http-equiv="refresh" content="10" > 

Next, we define a Delete button, which will load the del_data_lite.php page when clicked:

<input type="button" onclick="location.href = 'del_data_lite.php';" value="Delete"> 

Finally, we use the PHP code section to load the SQLite database and display the Channel 0 data.

We use the following PHP command to open the SQLite database we have previously stored data in (located at /var/databases/testsites/mydatabase.db):

$db = new PDO("sqlite:/var/databases/testsite/mydatabase.db"); 

Next, we use the following SQLite query to select all the entries where the zone includes 0: in the text (for example, 0:Light):

SELECT * FROM recordeddatarecordeddata WHERE itm_namename LIKE '%temp%''
Note that even though we are now using PHP, the queries we use with the SQLite database are the same as we would use when using the sqlite3 Python module.

We now collect the query result in the $response variable:

$response = $db->query($strSQL); 
Allowing us to use fetch() (like we used cursor.fetchall() previously) to list all the data columns in each of the data entries within the response. 
while($column = $response->fetch()) 
{ 
   //Display the content of the response 
   echo $column[0] . " "; 
   echo $column[1] . " "; 
   echo $column[2] . " "; 
   echo $column[3] . "<br />"; 
} 
?> 

The del_data_lite.php file is fairly similar; it starts by reopening the mydatabase.db file as before. It then executes the following SQLite query:

DROP TABLE recordeddata 

As described in the There's more... section, this will remove the recordeddata table from the database. If the response isn't equal to 1, the action was not completed. The most likely reason for this is that the directory that contains the mydatabase.db file isn't writable by the web server (see the note in the How to do it... section about changing the file owner to www-data).

Finally, we provide another button that will take the user back to the show_data_lite.php page (which will show that the recorded data has now been cleared):

Show_data_lite.php
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.137.217.220