<?php
$temp=$_GET["temp"];
$hum=$_GET["hum"];
$senzor=$_GET["senzor"];
$time = date("d.m.Y G:i:s");
$id=1;
$server = "KABINET\SQLEXPRESS";
$options = array( "UID" => "arduino", "PWD" => "arduino", "Database" => "temp_senzor");
$conn = sqlsrv_connect($server, $options);
if ($conn === false) die(print_r(sqlsrv_errors(), true));
echo "Successfully connected!";
$sql = "SELECT LAST(id) FROM dbo.meritve";
$query = sqlsrv_query($conn, $sql);
//preberemo id zadnjega elementa
while ($row = sqlsrv_fetch_array($query))
{
$id = $row['id'] + 1;
}
$sql = "INSERT INTO dbo.meritve (id, temp, hum, time, senzor_id) VALUES
('".$id."','".$temp."','".$hum."','".$time."','".$senzor."')";
$query = sqlsrv_query($conn, $sql);
sqlsrv_close($conn);
?>