O
O
oldfag3222018-05-02 09:08:29
JavaScript
oldfag322, 2018-05-02 09:08:29

How to get a value from a mysql table using php to convert to json and then operate on it in javascript?

I have a task book. And according to the assignment, I need to add a function for displaying notifications. The user specifies the time it is recorded in the database. And when the page is loaded, all data from the database goes to json, from there to an array that checks every 10 seconds whether the condition is true (the time specified by the user and the present time).

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
frees2, 2018-05-02
@oldfag322

It's primitive, but it's reliable... json_name= can already be written in the script, so that it would be more convenient to read later

var a = json_name={
name: ''+event.target.id+'',
time: '<?php echo''.$fulluri2.'' ; ?>',
 c: ' собака <?php  echo ''.$list.''; ?>'
};
var dAnimal = JSON.stringify(a);

K
Kairat Ubukulov, 2018-05-02
@ubukulov

Connecting to a database in PHP.

$mysqli = new mysqli("HOSTNAME","USERNAME", "PASSWORD", "DATABASE");
$mysqli->query("SET NAMES utf8");

$result = $mysqli->query("SELECT * FROM users");
return json_encode($result); // полученные данные преобразует в JSON

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question