My view.php page comes from another page by getting a unique id which is serial. Now in my view.php page I want to show that specified serial no data from charts.php. I have done my code by myself. It is fetching the data. But not that selected serial no. How can I solve this
view.php
<?php
if(isset($_GET['serial'])){
$serial = $_GET['serial'];
?>
<html>
<div class="container" id="output"></div>
</html>
<script>
$(document).ready(function(){
function getData(){
$.ajax({
type: 'POST',
url: 'charts.php',
success: function(data){
$('#output').html(data);
}
});
}
getData();
setInterval(function () {
getData();
}, 1000); // it will refresh your data every 1 sec
});
</script>
charts.php
<?php
$sql = mysqli_query($con,"SELECT * FROM criminal WHERE rand = '$serial'");
while($row = mysqli_fetch_assoc($sql)){
?>
Please help.