forked from SilverTab/moodatatable
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpost.php
More file actions
31 lines (23 loc) · 777 Bytes
/
post.php
File metadata and controls
31 lines (23 loc) · 777 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
$db = mysql_connect('localhost', 'root', '');
mysql_select_db('development', $db);
$entriesCount = mysql_query("SELECT COUNT(*) FROM `dummy`");
$counta = mysql_fetch_row($entriesCount);
$count = $counta[0];
$page = $_GET['page'];
$perPage = $_GET['perPage'];
$sort = $_GET['sort'];
$sortOrder = $_GET['sortOrder'];
$start = ($page * $perPage) - ($perPage);
$entries = mysql_query("SELECT * FROM `dummy` ORDER BY $sort $sortOrder LIMIT $start, $perPage");
$result = "{\"total\": $count,
\"page\": $page,
\"rows\": [
";
while($entry = mysql_fetch_assoc($entries)) {
$result = $result . "[\"$entry[id]\", \"$entry[name]\", \"$entry[email]\"],\n";
}
$result = substr($result, 0, strlen($result)-2);
$result = $result."\n]}";
echo $result;
?>