<?php

//connect to the database include("secret.php");

$ShowSensorValue=$_GET["sensorValue"];

  1. $Array["id"]=trim
  2. ($Array["id"]);

//$ShowPhotoValue =trim($ShowPhotoValue); //$ShowSensorValue =trim($ShowSensorValue);

//connect to database $host = "localhost"; $user = "mjh348"; $pass = "Fikb5dL"; $db = "mjh348"; $table = "values";

$date = date("Y-m-d"); $time = date("H:i:s");

$Link=mysql_connect($host,$user,$pass);

//if ($ShowPhotoValue !=null && $ShowSensorValue !=null && $ShowEMF !=null){ if ($ShowSensorValue !=null){

//$Query= "INSERT into $table values ('0', '$ShowSensorValue', '$date', '$time')"; $sql = "INSERT INTO `values` VALUES ('0', '$ShowSensorValue', '$date', '$time')";

echo ("the query is:<br>$sql<P></n>");

if (mysql_db_query ($db, $sql, $Link)) { echo ("The query was successfully executed<br><br><br>\n"); } else { echo ("the query could not be sent<br><br><br>\n"); }

} else { echo ("NO DATA TO SEND!!<br><br><br>\n"); }

//$id = $_GET['ID'];

function readFromdb () {

	global $host;
	global $user;
	global $pass;
	global $db;
	global $Link;

$query = "SELECT * FROM `values`";

		$result = mysql_db_query ($db, $query, $Link);

if ($Link) {

echo "<b>What is in my Database:</b>";

echo "<br><br>";

	while ($data = mysql_fetch_array($result)) {	
			$id=$data['id'];
			$sensor = $data['sensorValue'];
			$date = $data['date'];
			$time = $data['time'];




		//	echo   '<li><a href="list.php?sid='.$ci.'">'.$loc.'</a></li>';
			echo '<p>No. ='.$id.'  Sensor value='.$sensor.' date = '.$date.' time = '.$time.' </p>';

}

} else { echo "<p>couldnt read</p>"; } //close if

mysql_close ($Link); } //close fxn

readFromdb();

?>

Back