//Index.php
<ul id="">
<div id="carlist">
</div>
</ul>
//script
<script>
$(document).ready(function () {
var listtt = setInterval(function () {
$.ajax({
url: "list.php",
success: function (html) {
let listtt = html;
if (listtt) {
document.getElementById("carlist").innerHTML = listtt;
}
} });
} , 5000)
$('.a').click(function () {
carId = $(this).attr("abc");
alert (carId);
});
});</script>
//list.php
$query = mysqli_query($con, "SELECT * FROM tblproduct");
while($data = mysqli_fetch_assoc($query))
{
print '<li class="get_car" car_id="'. $data['id'].'"><span>'.$data['name'].'</span><button class="a" abc="'. $data['id'].'" type="button">hello</button></li>';
}