Answer the question
In order to leave comments, you need to log in
How to display data from the database using server-side js?
Good day everyone! Now I'm pulling data from the database using Ajax and PHP like this:
let Howaquou = '';
$.ajax({
url: 'скрипт.php',
method: 'POST',
dataType: 'json',
data: {'type' : 'pack'},
success: function(Buqhou){
for(let Beou = 0; Beou <= Buqhou.length - 1; Beou++){
Howaquou += '<div class="Noenex">' +
'<img src="' + window.location + 'img/' + Buqhou[Beou].RepackCode + '/' + Buqhou[Beou].Cover + '" />' +
'</div>';
document.getElementsByClassName('Deff')[0].innerHTML = Howaquou;
}
}
});
@include($_SERVER['DOCUMENT_ROOT'] . '/bd.php');
if(isset($_POST)){
$type = trim($_POST['type']);
$result = "SELECT * FROM `$type` WHERE `Play` = '123'";
$query = @mysqli_query($connect, $result) or die(mysqli_error());
while($row = mysqli_fetch_assoc($query)){
$array[] = $row;
};
$json = defined('JSON_UNESCAPED_UNICODE')
? json_encode($array, JSON_UNESCAPED_UNICODE)
: json_encode($array);
echo $json;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question