too long

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 ?

Without knowing anything about your database, is hard to give you a code that "just works".

I suggest you take a look at the following example which shows you how to use the native IndexedDB API.

Also, I suggest you (if you want to make it easier) to use a library to manage IndexedDB. For example Dexie.

Just remember that first, you have to create a Schema which is the representation of your data (in mysql, the structure of the table) then once your schema is created, you can start adding data to the IndexedDB.

I hope it helps