I think that you are trying to return a JSON response to be used in another part of your code.
To get a JSON response you can try it:
...
// Print out rows.
$response = array();
while ( $row = mysql_fetch_assoc( $result ) )
{
$response[] = array('pin_status' => $row['pin_status'], 'rep_empid' => $row['rep_empid'], 'rep_email' => $row['rep_email'], 'rep_username' => $row['rep_username']);
}
// Response JSON.
header( "Content-Type: application/json" );
// Convert array to JSON.
$response = json_encode($response);
echo $response;
// Close the connection
mysql_close($link);
?>
I supose you will show the table into a new file, you created a new file to show this JSON response? How is the structure of this file.
Are you confused about how to use AJAX ?
Using bootstrap as part of the solution, your Filename.php may looks like this:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>stackoverflow.com</title>
<!-- Bootstrap -->
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
</head>
<body>
<div id="contents" class="row">
<div class="col-md-3">pin_status</div>
<div class="col-md-3">rep_empid</div>
<div class="col-md-3">rep_email</div>
<div class="col-md-3">rep_username</div>
</div>
<div id="htmldata"></div>
<script type="text/javascript">
jQuery.ajax({
type: "GET",
url: "json.php",
dataType: "json",
success: function(response){
$.each(response, function(key, value){
var html = '' +
'<div class="col-md-3">'+value.pin_status+'</div>'+
'<div class="col-md-3">'+value.rep_empid+'</div>'+
'<div class="col-md-3">'+value.rep_email+'</div>'+
'<div class="col-md-3">'+value.rep_username+'</div>';
$("#contents").append(html);
});
}
});
</script>
</body>
</html>
Note that on this solution the json.php file need to stay on the same domain name of the Filename.php .