Trying to delete a row after clicking a delete button, but even there's no error, it doesn't work. At first I thought that it has to do with the if statements but nothing changed...Here's my delete code! Is there any other way? Thank you
<?php
echo "<table>
<caption>Λίστα Χρηστών</caption>
<thead>
<tr>
<th scope='col'>Ιd</th>
<th scope='col'>Χρήστης</th>
<th scope='col'>Διαγραφή</th>
</tr>
</thead>";
$servername = "localhost";
$username = "root";
$password = "";
$db = "aws_chat";
// Create connection
$conn = new mysqli($servername, $username, $password,
$db);
// Check connection
$sql = "SELECT username,email,id FROM users WHERE
user_type='user'";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
if (isset($_GET['del'])) {
$del = $_GET['del'];
//SQL query for deletion.
$sql_del = "DELETE * FROM users WHERE id=$del";
}
while($row = $result->fetch_assoc()) {
echo "<tbody>
<tr>
<td>".$row["id"]."</td>
<td>".$row["username"] ."</td>
<td><a href='delete_user.php?del=
{$row['id']}'><input type='button' class='btn_del'
value='Delete'/></td>
</tr>
</tbody>
<tfoot>
</tfoot>";
}
} else {
echo "0 results";
}
echo "</table>";
?>
</center></div>
change
DELETE * FROM users WHERE id=$del
to
DELETE FROM users WHERE id=$del
//SQL query for deletion.
$sql_del = "DELETE FROM users WHERE id='".$del."' ";
$conn->query($sql_del); // you missed this line which is required to delete the record from database
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed last year.
Improve this question
I am trying to create a live search using ajax, jquery, php and mysql.
The user enter some inputs, it send the search to form_livesearch.php. I got that part worked. Else if the input is empty, then display other query. (I need help with this part)
<div id="container" class="col-md-12">
<div class="row">
<h2>Quick Search</h2>
<input class='form-control' type="text" id='live_search' placeholder='Search our inventory'>
<br>
<br>
<h2 class="" id="searchresult">
</h2>
</div>
</div>
$(document).ready(function(){
$("#live_search").keyup(function(){
var input = $(this).val();
if(input != ""){
$.ajax({
url:"form_livesearch.php",
method:"POST",
data:{input:input},
success:function(data){
$("#searchresult").html(data);
$("#searchresult").css("display","block");
}
});
} else {
// If the input field is empty
// How display another php query here?
}
});
});
Here is the php and mysql I am trying to display when the input field is empty.
<?php
$query = "SELECT * FROM `my_db` . `my_table` WHERE s_category = 'policy' ORDER BY id ASC";
$result = mysqli_query($db,$query);
if(!$result){
die("Query Failed " . mysqli_error($db));
}
if(mysqli_num_rows($result) > 0){
?>
<h3>Policies</h3>
<ul>
<?php
while($row = mysqli_fetch_assoc($result)){
$id = $row['id'];
$s_url = $row['s_url'];
$s_name = $row['s_name'];
$s_category = $row['s_category'];
?>
<li><?php echo $s_name?> <img src="https://www.xxxxxxx.xxx/xxxx/images/pdf.gif" alt="PDF"></li>
<?php
}
?>
</ul>
<?php
}
?>
form_livesearch.php:
if(isset($_POST['input'])){
$input = $_POST['input'];
//to prevent from mysqli injection
// x'='x
$input = stripcslashes($input);
$input = mysqli_real_escape_string($db, $input);
$input = str_replace('%', ' #', $input);
$input = str_replace("'", ' #', $input);
$query = "SELECT * FROM `my_db` . `my_table` WHERE s_name LIKE '%{$input}%' ORDER BY id ASC";
$result = mysqli_query($db,$query);
if(mysqli_num_rows($result) > 0){?>
<table class="table table-bordered table-striped mt-4">
<!--
<thead>
<tr>
<th>id</th>
<th>name</th>
</tr>
</thead>
-->
<tbody>
<?php
while($row = mysqli_fetch_assoc($result)){
$id = $row['id'];
$s_url = $row['s_url'];
$s_name = $row['s_name'];
$s_category = $row['s_category'];
?>
<tr>
<td style="font-size: 14px;"><?php echo $s_name;?> <img src="https://www.xxxxx.xxxx/xxxxx/images/pdf.gif" alt="PDF"></td>
</tr>
<?php
}
?>
</tbody>
</table>
<?php
}else{
echo "<h6 class='text-danger text-center mt-3'>No data Found</h6>";
}
}
?>
You should handle this stuff in the PHP file. and by the way, the input can not be empty as you put the ajax in keyup event.
it just happened when the user use the backspace to delete what he search.
So the form_livesearch.php PHP file should be something like this.
<?php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "myDB";
// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
$output = "";
if(isset($_POST['input'])){
$input = $_POST['input'];
if(!empty($input)){
$input = str_replace('%', ' #', $input);
$input = str_replace("'", ' #', $input);
$input = "%$input%"; // prepare the $input variable
$query = "SELECT * FROM `my_db` . `my_table` WHERE s_name LIKE ? ORDER BY id ASC";
$stmt = $conn->prepare($query);
$stmt->bind_param("s", $input); // here we can use only a variable
$stmt->execute();
}else{
$query = "SELECT * FROM `my_db` . `my_table` WHERE s_category = 'policy' ORDER BY id ASC";
$stmt = $conn->prepare($query);
$stmt->execute();
}
$result = $stmt->get_result(); // get the mysqli result
if($result->num_rows > 0){
if(empty($input))
$output = '<table class="table table-bordered table-striped mt-4"><tbody>';
else
$output = '<h3>Policies</h3><ul>';
while($row = $result->fetch_assoc()){
$id = $row['id'];
$s_url = $row['s_url'];
$s_name = $row['s_name'];
$s_category = $row['s_category'];
if(empty($input))
$output .= '
<tr>
<td style="font-size: 14px;">' . $s_name .' <img src="https://www.xxxxx.xxxx/xxxxx/images/pdf.gif" alt="PDF"></td>
</tr>';
else
$output .= '<li>' . $s_name . ' <img src="https://www.xxxxxxx.xxx/xxxx/images/pdf.gif" alt="PDF"></li>';
}
if(empty($input))
$output .= '</tbody></table>';
else
$output .= '</ul>';
echo $output;
}else{
echo "<h6 class='text-danger text-center mt-3'>No data Found</h6>";
}
}
?>
You can use a separate file to handle 2 types but as they are all about products it's better to have one file.
It's a good practice to return the data and let the frontend build the HTML output but if you want to build HTML in the PHP file, it's better to wrap them in a string.
Also, use the prepare statement of MySQLi to prevent SQL injection. take a look at this example for more information.
And the html file should be something like this:
<div id="container" class="col-md-12">
<div class="row">
<h2>Quick Search</h2>
<input class='form-control' type="text" id='live_search' placeholder='Search our inventory'>
<br>
<br>
<h2 class="" id="searchresult">
</h2>
</div>
</div>
<script type="text/javascript">
$(document).ready(function(){
// will execute once the page load
getData();
$("#live_search").keyup(function(){
let input = $(this).val();
getData(input);
});
});
function getData(input = ''){
$.ajax({
url:"form_livesearch.php",
method:"POST",
data:{input:input},
success:function(data){
$("#searchresult").html(data);
$("#searchresult").css("display","block");
}
});
}
</script>
So I've came across an issue that I'm having regarding a textarea. My goal is to have a form with a textarea where a user can enter an alphanumeric name line by line and then it would pull that information from a database and display it into a table.
For example:
tt1
tt2
tt3
and on submit it would return all of the data associated with those 3 names.
I can get the textarea, parse it and get the raw values to be inserted into the sql query, but I'm getting stuck at outputting the results.
My code for now is as follows:
index.html
<form method="POST" action="getreport.php">
<div class="form-group">
<label for="textarea">Textarea</label>
<textarea class="form-control" name="textarea" id="textarea" class="textarea" rows="5" cols="50"></textarea>
</div>
<button type="submit" class="btn btn-primary" >Submit</button>
</form>
getreport.php
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "server";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$text = trim($_POST['textarea']);
$textAr = preg_split('/[\n\r]+/', $text); //<--- preg_split is where the magic happens
$textAr = array_filter($textAr, 'trim'); // remove any extra \r characters left behind
foreach ($textAr as $line) {
// processing here.
$sql = "SELECT * from guestlist WHERE guestname='$line'";
echo "$sql"; //just checking query output for now
}
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) { //<---- take this while loop out
echo '<table class="table table-striped table-bordered table-hover">';
echo "<tr><th>Hostname</th><th>Guestname:</th><th>date</th><th>owner</th></tr>";
while($row = mysqli_fetch_array($result))
{
echo "<tr><td>";
echo $row['hostname'];
echo "</td><td>";
echo $row['guestname'];
echo "</td><td>";
echo $row['date'];
echo "</td><td>";
echo $row['owner'];
echo "</td></tr>";
}
echo "</table>";
} //<-----as well as the closing bracket
} else {
echo "0 results";
}
$conn->close();
?>
Any help or guidance on this would be appreciated.
Thanks
Not sure your approach to the problem is the correct one, and also as someone suggested you should be worried about SQL injection. Said that, this could be one solution:
$text = trim($_POST['textarea']);
$textAr = str_replace("/n",",", $text);
$sql = "SELECT * from guestlist WHERE FIND_IN_SET(guestname,'$line')>0";
$result = $conn->query($sql);
Another way could be just iteratin every time
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "server";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$text = trim($_POST['textarea']);
$textAr = explode("/n", $text);
$textAr = array_filter($textAr, 'trim'); // remove any extra \r characters left behind
foreach ($textAr as $line) {
// processing here.
$sql = "SELECT * from guestlist WHERE guestname='$line'";
echo "$sql"; //just checking query output for now
$result = $conn->query($sql);
// <---------------- ITERATE INSIDE THE FOREACH
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo '<table class="table table-striped table-bordered table-hover">';
echo "<tr><th>Hostname</th><th>Guestname:</th><th>date</th><th>owner</th></tr>";
while($row = mysqli_fetch_array($result))
{
echo "<tr><td>";
echo $row['hostname'];
echo "</td><td>";
echo $row['guestname'];
echo "</td><td>";
echo $row['date'];
echo "</td><td>";
echo $row['owner'];
echo "</td></tr>";
}
echo "</table>";
}
} else {
echo "0 results";
}
} // Close the foreach
$conn->close();
?>
Not sure why you used 2 while loops - fetch_assoc and mysqli_fetch_array? Each call here moves the pointer to the next row. Maybe that's why your table is not displaying correct data? It seems you can remove the fetch_assoc loop.
I'm just trying Ajax for the first time, with PHP, and I'd like to avoid using JQuery for now.
I got it to send back 1 list of states wrapped in a drop down element. woo hoo!
Now when I added JSON to return 2 values to be parsed back out (wrapped in an array - one a string, and one am array), it's not working. I suspect that the data is getting passed around property, but a headers-warning-message is being appended at the front of the return req so the entire string can't properly be parsed. Seems to be just a header issue of some sort. I'm not familiar with header stuff so I'm not sure where to go next. I have now pasted that content below.
Main Page:
<?php
$servername = "localhost";
$username = "xxx";
$password = "xxx";
$dbname = "xxx";
// Create connection
$con = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($con->connect_error)
{
die("Connection failed");
}
$sql = 'SELECT country_name, country_id
FROM countrylist
ORDER BY 1';
$stmt = $con->prepare($sql);
$stmt->execute();
$result = $stmt->get_result();
//Create entry form on page
echo
"<form action = 'searchresults.php' method='post'>
<h1>FIND A PET SITTER</h1>
<br/>
Enter either a ZipCode
<table>
<tr>
<td style='text-align:right'>
Zip Code:
</td>
<td>
<input name='search_zip'></input>
</td>
</tr>
<br/><br/>
Or Country, City, and State
<tr>
<td style='text-align:right'>";
echo "Country: <td>
<select onChange='getState(this.value)' name='search_country' value=''>";
while ($row = $result->fetch_assoc())
{
if ($row[country_name] == 'United States of America')
{
echo "<option value ='".$row['country_id']."' selected>".$row['country_name']." </option>
";
}
else
{
echo "<option value='".$row['country_id']."'> ".$row['country_name']."</option>
";
}
}
echo
"
</select>
</td>
</tr>
<tr>
<td style='text-align:right'>
City:
</td>
<td>
<input name='search_city'>
</input>
</td>
</tr>
<tr>
<td style='text-align:right'>
<div id='statelab'></div>lab
</td><td>
<div id='statediv'></div>div
</td>
</tr>
</table>
<input type='submit'>
</input>
</form>";
?>
<script>
function getState(countryId) {
var strURL="getStates.php?countryIn="+countryId;
var req = new XMLHttpRequest();
if (req) {
req.onreadystatechange = function() {
if (req.readyState == 4) {
// only if "OK"
if (req.status == 200) { //if success
alert(req.responseText);
var obj = JSON.parse(req.responseText);
document.getElementById('statediv').innerHTML=obj.stateselectbox;
document.getElementById('statelab').innerHTML=obj.statelabel;
}
else {
alert("Problem while using XMLHTTP:\n" + req.statusText);
}
}
}
req.open("GET", strURL, true);
req.send(null);
}
}
getState(230);/*united states*/
</script>
Ajax calls this page:
<?php
$servername = "localhost";
$username = "xxx";
$password = "xxx";
$dbname = "xxx";
// Create connection
$con = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$countryId = intval($_GET["countryIn"]);
if ($countryId < 1 || $countryId > 1000) exit();
$sql = 'SELECT divisions_are_called
FROM countrieslist
WHERE country_id = 0'.$countryId ;
$result = mysqli_query($con, $sql);
$row = mysqli_fetch_assoc($result);
$divisionsAreCalled = $row[divisions_are_called];
//echo $divisionsAreCalled.': </td><td>';
$sql = 'SELECT state_name
FROM stateslist
WHERE state_name <> ""
AND country_id = 0'.$countryId . '
ORDER BY 1' ;
$result = mysqli_query($con, $sql);
$stateSelectBox = '<select name="statename">';
while ($row = mysqli_fetch_assoc($result))
{
$stateSelectBox=$stateSelectBox. '<option value="'.$row["state_name"].'">'.$row["state_name"].'</option>';
}
$stateSelectBox=$stateSelectBox. '</select>';
$data=array('divisionsarecalled'=>$divisionsAreCalled,
'stateselectbox'=>$stateSelectBox);
//header('Content-Type: application/javascript');
header('Content-Type: application/json');
echo JSON_encode($data);
?>
Here is the response:
<br />
<b>Warning</b>: Cannot modify header information - headers already sent by (output started at /home/professional/www/dan/myFiles/getStates.php:2) in <b>/home/professional/www/dan/myFiles/getStates.php</b> on line <b>43</b><br />
{"statelabel":"State","stateselectbox":"<select name=\"devices\"><option value=\"Alabama\">Alabama<\/option><option value=\"Alaska\">Alaska<\/option><option value=\"American Samoa\">American Samoa<\/option><option value=\"Arizona\">Arizona<\/option><option value=\"Arkansas\">Arkansas<\/option><option value=\"Armed Forces Americas\">Armed Forces Americas<\/option><option value=\"Armed Forces Europe\">Armed Forces Europe<\/option><option value=\"Armed Forces Pacific\">Armed Forces Pacific<\/option><option value=\"California\">California<\/option><option value=\"Colorado\">Colorado<\/option><option value=\"Connecticut\">Connecticut<\/option><option value=\"Delaware\">Delaware<\/option><option value=\"Florida\">Florida<\/option><option value=\"Georgia\">Georgia<\/option><option value=\"Guam\">Guam<\/option><option value=\"Hawaii\">Hawaii<\/option><option value=\"Idaho\">Idaho<\/option><option value=\"Illinois\">Illinois<\/option><option value=\"Indiana\">Indiana<\/option><option value=\"Iowa\">Iowa<\/option><option value=\"Kansas\">Kansas<\/option><option value=\"Kentucky\">Kentucky<\/option><option value=\"Louisiana\">Louisiana<\/option><option value=\"Maine\">Maine<\/option><option value=\"Maryland\">Maryland<\/option><option value=\"Massachusetts\">Massachusetts<\/option><option value=\"Michigan\">Michigan<\/option><option value=\"Minnesota\">Minnesota<\/option><option value=\"Mississippi\">Mississippi<\/option><option value=\"Missouri\">Missouri<\/option><option value=\"Montana\">Montana<\/option><option value=\"Nebraska\">Nebraska<\/option><option value=\"Nevada\">Nevada<\/option><option value=\"New Hampshire\">New Hampshire<\/option><option value=\"New Jersey\">New Jersey<\/option><option value=\"New Mexico\">New Mexico<\/option><option value=\"New York\">New York<\/option><option value=\"North Carolina\">North Carolina<\/option><option value=\"North Dakota\">North Dakota<\/option><option value=\"Northern Mariana Islands\">Northern Mariana Islands<\/option><option value=\"Ohio\">Ohio<\/option><option value=\"Oklahoma\">Oklahoma<\/option><option value=\"Oregon\">Oregon<\/option><option value=\"Pennsylvania\">Pennsylvania<\/option><option value=\"Puerto Rico\">Puerto Rico<\/option><option value=\"Rhode Island\">Rhode Island<\/option><option value=\"South Carolina\">South Carolina<\/option><option value=\"South Dakota\">South Dakota<\/option><option value=\"Tennessee\">Tennessee<\/option><option value=\"Texas\">Texas<\/option><option value=\"U.S. Virgin Islands\">U.S. Virgin Islands<\/option><option value=\"Utah\">Utah<\/option><option value=\"Vermont\">Vermont<\/option><option value=\"Virginia\">Virginia<\/option><option value=\"Washington\">Washington<\/option><option value=\"Washington DC\">Washington DC<\/option><option value=\"West Virginia\">West Virginia<\/option><option value=\"Wisconsin\">Wisconsin<\/option><option value=\"Wyoming\">Wyoming<\/option><\/select>"}
EDIT: I added changed these 3 lines in the page ajax calls and it works now:
<?php
ob_start(); //<--ADDED THIS
$servername = "localhost";
$username = "xxx";
$password = "xxx";
$dbname = "xx ...
...$data=array('statelabel'=>$divisionsAreCalled,
'stateselectbox'=>$stateSelectBox);
header('Content-Type: application/javascript');
//echo json_encode($data); //<--CHANGED THIS TO THE 2 LINES BELOW
ob_end_clean(); // this clears any potential unwanted output
exit(json_encode($data));
?>
I have written a table in html and made its rows contenteditable if user hits the edit button.
this table's data are coming from an mysql database. I want my user to be able to change the content editable fields and after hitting the save button changes send to mysql table again.
so firstly, i want to know how to save content editable changes in a string variable so i can be able to POST them to database. followings are my related codes:
<?php
$servername = "localhost";
$username = "hevak_neshat";
$password = "shir moz peste";
$dbname = "hevak_android_api";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT * FROM beacons";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
echo "<thead>
<tr>
<th>Major number</th>
<th>Minor number</th>
<th>Client</th>
<th>Location</th>
<th>Link to ad</th>
<th>Attachment</th>
<th>Edit</th>
</tr>
</thead>";
echo "<tbody>";
while ($row = $result->fetch_assoc()) {
echo "<tr><td>" . $row["major"] . "</td><td>" . $row["minor"] . "</td><td>" . $row["client"] . "</td><td>" . $row["geolocation"] . "</td><td>" . $row["linktoadd"] . "</td><td>" . $row["attacment"] . "</td><td>";
echo "<button class=\"editbtn\">Edit</button>";
echo "<td><button class=\"savebtn\">Save</button></td>";
echo "</td>";
echo "</tr>";
}
echo "</tbody></table>";
} else {
echo "no results";
}
?>
And my Javascript:
$(document).on("click", ".editbtn", function (event) {
event.preventDefault();
alert("click on items to edit");
var currentTD = $(this).parents('tr').find('td');
if ($(this).html() == 'Edit') {
$.each(currentTD, function () {
$(this).prop('contenteditable', true)
});
} else {
$.each(currentTD, function () {
$(this).prop('contenteditable', false)
});
}
});
Update:
in my code i used content editable. but if anyone has any idea of moving user changes in a table to a database please tell me, even if it is a whole other way. just a table with ability to edit content and moving the content to db.
Here is the situation... Two results are created in the php page.. The results are echoed as json_encode . The results are showing perfectly. But when i insert a javascript code within two php code blocks, then one result is shown while the other is not.. I really have no idea why this is happening.. My code
$action = isset($_GET['action']);
if($action == "get_requests"){
include("../connect.php");
$sql_song_req = "SELECT COUNT(*) FROM `song_requests`";
$sql_select_song = "SELECT * FROM `song_requests` ORDER BY id ASC";
$sql_count = $rad->prepare($sql_song_req);
$sql_count->execute();
$count = $sql_count->fetchColumn();
$select_song_prep = $rad->prepare($sql_select_song);
$select_song_prep->execute();
while($row = $select_song_prep->fetch(PDO::FETCH_ASSOC)){
$id = $row['id'];
$name = $row['name'];
$song = $row['songname'];
$dedicatedto = $row['dedicatedto'];
?>
<script>
function delete_req(id){
alert("hello");
}
</script>
<?php
$data .= ' <tr cellpadding="5" cellspacing="6" align="center" width="60%">
<td>'.$id.'</td>
<td>'.$name.'</td>
<td>'.$song.'</td>
<td>'.$dedicatedto.'</td>
<td>Delete</td>
</tr>';
}
$display = ' <table "cellspacing="4" align="center">
<tr>
<th>ID</th>
<th>Name</th>
<th>Song</th>
<th>Dedicated to</th>
<th>Delete</th>
'.$data.'
</tr>
</table>';
$response = array();
$response['data_from_db'] = $display;
$response['count'] = $count;
echo json_encode($response);
}
Here the response['count'] is showing on my php page but not $response['data_from_db'].
And when I delete the javascript code then both of them are showing.. Help needed.
I should mention that am using NGINX and php5-fpm
You have a brace mismatch.
Add a brace } after $dedicatedto = $row['dedicatedto']; Your while loop wasn't properly closed.
$action = isset($_GET['action']);
if($action == "get_requests"){
include("../connect.php");
$sql_song_req = "SELECT COUNT(*) FROM `song_requests`";
$sql_select_song = "SELECT * FROM `song_requests` ORDER BY id ASC";
$sql_count = $rad->prepare($sql_song_req);
$sql_count->execute();
$count = $sql_count->fetchColumn();
$select_song_prep = $rad->prepare($sql_select_song);
$select_song_prep->execute();
while($row = $select_song_prep->fetch(PDO::FETCH_ASSOC)){
$id = $row['id'];
$name = $row['name'];
$song = $row['songname'];
$dedicatedto = $row['dedicatedto'];
} // <- added. Brace for while loop
?>
<script>
function delete_req(id){
alert("hello");
}
</script>
<?php
$data .= ' <tr cellpadding="5" cellspacing="6" align="center" width="60%">
<td>'.$id.'</td>
<td>'.$name.'</td>
<td>'.$song.'</td>
<td>'.$dedicatedto.'</td>
<td>Delete</td>
</tr>';
$display = ' <table "cellspacing="4" align="center">
<tr>
<th>ID</th>
<th>Name</th>
<th>Song</th>
<th>Dedicated to</th>
<th>Delete</th>
'.$data.'
</tr>
</table>';
$response = array();
$response['data_from_db'] = $display;
$response['count'] = $count;
echo json_encode($response);
}