Last active
July 12, 2017 23:30
-
-
Save AriPal/e8977abdff6d6bc2cbd478941afc3ace to your computer and use it in GitHub Desktop.
In short, I have defined my table in html file, then I use ajax with jQuery to retreive the html content with data from php file. I believe the problem has something to do with the timing, causing the table not to load properly.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
updateTable: function(value){ | |
$.ajax({ | |
type: "GET", | |
url: "service.php?p=getRows", | |
success: function(tableData){ | |
$('#adminView').html(tableData); | |
// alert(tableData); | |
} | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- class="table-responsive" --> | |
<div id="displayTable"> | |
<table | |
data-toggle="table" | |
data-striped="true" | |
data-pagination="true" | |
data-page-list="[5, 10, 20, 50, 100, 200]" | |
data-search="true" | |
data-height="500" id="mainOverview" id="mainOverview"> | |
<thead> | |
<th>Full Name</th> | |
<th>Plate Number</th> | |
<th>company name/th> | |
<th>Description</th> | |
</thead> | |
<tbody id="adminView"> | |
<!--Data goes here--> | |
</tbody> | |
</table> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Retrieve data | |
$stmt = $db->prepare("SELECT * FROM crud ORDER BY id desc"); | |
// Execute query | |
$stmt->execute(); | |
// Fetch data | |
while($row = $stmt->fetch()){ | |
// Inject backend data to frontend | |
?> | |
<tr> | |
<td><?php echo $row['fullname']?></td> | |
<td><?php echo $row['platenumber']?></td> | |
<td><?php echo $row['companyname']?></td> | |
<td><?php echo $row['description']?></td> | |
</tr> | |
<?php | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment