0

I do not want to set the limit for this chart.

How to delete it to work?

Code:

$sql = "(SELECT (UNIX_TIMESTAMP(timestamp)*1000) AS time ,IFNULL(hodnota,'null')AS temperature
                FROM arduino_data ORDER BY timestamp DESC LIMIT 60) ORDER BY time ASC";
$result = $conn->query($sql);
 
if ($result->num_rows>0){
$count =0;
echo '[';
while($row=$result->fetch_assoc()){      
      echo '['.$row["time"].',' .$row["temperature"].']';
      $count++;
       if ($count<"60"){
       echo ',';
       }      
     }
     echo ']';
}else{
echo "[[],[]]";
}
$conn->close();

Printscreen to understand: here

Thank :), sorry for my bad English :/

Mike Zavarello
  • 3,514
  • 4
  • 29
  • 43
  • Why do you have to have a limit set on your SQL query? I assume from your code that you are using MySQL ... is that right? You may want to read these pages: 1) https://stackoverflow.com/q/2294842/2596103; 2) https://www.geeksforgeeks.org/sql-limit-clause/ (see the part on "LIMIT ALL") – Mike Zavarello Jul 20 '18 at 11:14
  • Yes, i usage mysql – Tomáš Friedl Jul 20 '18 at 11:33
  • It's not clear what the question is. If you want to remove the limit, just remove it :) I would suggest reworking your loop completely, and use php's json_encode() function rather than trying to build a javascript object structure the way that you currently are. – jlbriggs Jul 20 '18 at 19:47
  • I apologize for the ambiguity. If I delete the limit, the data is incorrectly written to data.php. The comma separating the data is at the end and unfortunately the chart does not work. It sets itself up to how many results it ought to omit the comma and unfortunately when it fades it does not fool it. Please enter the code. Perhaps everything is clear. Thanks – Tomáš Friedl Jul 20 '18 at 19:51
  • Hi Tomáš Friedl, maybe custom data preprocessing will solve your problem? https://www.highcharts.com/docs/working-with-data/custom-preprocessing – ppotaczek Jul 23 '18 at 11:50

0 Answers0