Hello
I have a function in javascript that reads the localStorage of the browser that represents the client ID and displays in a DIV the result of reading the localStorage. I would like javascript to bring the ID's of the clients allocated nolocalStorage and collect the database using a PHP query the name and general data of the client as the FOR loop is executed.
But I've never done this before, what better way to be doing it, in the right way. If possible, give me an example.
I've come this far:
function listarClientes()
{
for(i = 0; i <= 10; i++)
{
// Retrieve
var divInformacoesClientes = document.getElementById("divCliente");
divInformacoesClient.innerHTML += '<p>' + localStorage.getItem(i); + '</p>';
}
}
Current code with AJAX request.
$.get("carrinho_compras.php",
{id:compras_no_carrinho},
function(data)
{
//alert(data);
console.log(data);
document.getElementById("total").innerHTML += data ;
}, "html");
PHP code
<?php
include 'include/connection.php';
$id = $_GET['id'];
$query = "SELECT id, imagem, produto FROM produtos WHERE id = $id ORDER BY id ASC";
$result = mysqli_query($link, $query);
while ($row = mysqli_fetch_array($result))
{
echo $row[2];
}
?>
Error that is displayed when inserting (+ =) to concatenate all values received by the AJAX request.
Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in C:\xampp\htdocs\projetos\PaperList\carrinho_compras.php on line 11
Thank you.