I've posted a question a few days ago, but I'm not sure I exposed properly my problem, so I'd like to expose it in another way. I want to send the content of MySQL database into an IndexedDB database. I have this, on the PHP side:
$con = mysqli_connect("localhost", "root", $mypassword, $myDB);
if (!$con) {
die("Connection failed: " . mysqli_error($con));
}
$sql = "SELECT * FROM table1";
$result = mysqli_query($con, $sql);
$to_encode = array();
while($row = mysqli_fetch_array($result)) {
$to_encode[] = $row;
}
echo json_encode($to_encode);
mysqli_close($con);
and on the javascript side:
$.getJSON('./php/database.php', function(data) {
$.each(data, function (key, value) {
// Populate the IndexedDB database here
});
});
I'm pretty new to development and especially with IndexedDB so I have a hard time to understand the process. I'm not even sure if it's possible to do what I want. Can somebody help please ?