1
I need to mark checkboxs for a page of editing forms, the values are saved in a table where checkboxs that were marked in the register were stored, but I do not know how to pull these results and leave marked the same fields editing page, Treating each client would generate a lot of inconvenience because the searches are done via ajax which makes it a little difficult because my knowledge is greater in php. Results are generated in php through json_encode
Structure of the BD
CREATE TABLE produtos (
id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
id_cliente INT(6) NOT NULL,
id_produto INT(6) NOT NULL,
reg_date TIMESTAMP
)
Javascript structure
$.ajax({
type:'post',
dataType: 'json',
url: produtos.php',
data:{id:idcliente},
success: function(result){
//como colocar o resultado da busca aqui
}
}
});
Structure of PHP
<?php
require('conn/conn.php');
$cliente = $_POST['id'];
$qryprodutos = mysqli_query($con, "SELECT * FROM produtos where id_cliente=$cliente");
$num = $qryprodutos->num_rows;
if($num > 0){
while($resultado = mysqli_fetch_assoc($qryprodutos)){
$imprime[] = array("produto"=>$resultado['id_produto'];);
}
}