Database Fetch data ajax

I want fetch data from database in same page data fetching .but i want without refresh if any new entry in database inst.php


	
<table  class="table table-striped table-dark table-dark">

     <thead class="thead-dark">
      <tbody id="auto">
    <tr>
     
      <th>ID</th>
      <th scope="col">Namesss</th>
      <th scope="col">Email</th>
      <th scope="col">Image</th>
      <th scope="col">Update</th>
      <th scope="col">Delete</th>
    </tr>
  </thead>
  

		
		<?php
include "db.php";


$q="select * from users";
$ok=mysqli_query($con,$q);

while($raq=mysqli_fetch_array($ok)){






?>







<!DOCTYPE html>
<html lang="en">
<head>
  <title>Bootstrap Example</title>
  <meta charset="utf-8">
  <style type="text/css" media="screen">
  .link {
  color: white;
  font-size: 20px;
}

/* visited link */
a:visited {
  color: cyan;
}

/* mouse over link */
a:hover {
  background-color: red;
 
 
}

/* selected link */
a:active {
  color: yellow;
}
}
  	
  </style>
  <meta name="viewport" content="width=device-width, initial-scale=1">

  <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS" crossorigin="anonymous">

  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
 
</head>
<body>



	<tr>
    <td ><?php echo  $raq[1];?></td>
		<input   type=hidden name="id" value="<?php echo $raq[1]?>">
		<form  class="form-group" action="" method="post" accept-charset="utf-8" enctype="multipart/form-data" >
      
		<td><?php echo  $raq[0];?></td>
		<td><?php echo  $raq[2];?></td>
		<td><img   src="<?php echo "image/$raq[3]";?>"  height='50 width='50'></td>
		<?php echo "<td><button class='btn btn-primary''text-white'><a  class='link' href=hk.php?id=$raq[1]>Modify</a></td>"?></button>
		<?php echo "<td><button class='btn btn-danger''text-white'><a  class='link' href=del.php?id=$raq[1]>Delete</a></td>"?></button>
	</tr>

</tbody>
		</div>
<?php }?>
	</table>

</div>
</div>

</div>


	</body>

I use this code but page stucks. i want like bootbotsrap badge top of the table
above one div #1

[code]
$(document).ready( function(){
$(’#1’).load(‘inst.php’);
refresh();
});

function refresh()
{
setTimeout( function() {

refresh();

}, 3000);
}

I wouldn’t load the entire page, just the data.

Why are you loading the entire users table? What are you actually trying to monitor?

i just want if any body register page auto refresh .i want if some one registered auto refresh page
.i dont want this.1st pic i put id. code works but table shows like this after auto refresh structure change.this is with code.if some user register id goes to 10 auto.


my actual table is this.


<script>
setTimeout(function(){
   .load('inst.php');
}, 5000);
</script>

this code runs fine .but i want in ajax whole page auto refresh

You are doing a while loop that breaks the html. You can’t have a new html document for each person.

so how can i implement
help me with right code

I’m not going to just write your code for you, this isn’t a code writing service that waits for someone to come along.

Take what I said and fix that first.

its easy bro just rewrite whole div using ajax set all table using ajax instead of refresh page.

Sponsor our Newsletter | Privacy Policy | Terms of Service