Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- ini_set('display_errors', 1); error_reporting(-1);
- $servername="localhost";
- $username="root";
- $password="root123";
- $dbname="KP1db";
- $bateriaa=15;
- $czujnik_1=0;
- $czujnik_2=0;
- try {
- $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
- // set the PDO error mode to exception
- $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- echo "Connected successfully";
- }
- catch(PDOException $e){
- echo "Connection failed: " . $e->getMessage();
- }
- try {
- $sql = "SELECT * FROM dane2 ORDER BY lp DESC LIMIT 1";
- $row= $conn->query($sql);
- echo "Dane zostaly pobrane";
- }
- catch(PDOException $e){
- echo $sql . "<br>" . $e->getMessage();
- }
- json_encode($row);
- ?>
- ---JS
- setInterval(function(){
- &.getJSON("get.php",function(result){
- console.log(result);
- });
- }, 1/30 * 1000);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement