-
Notifications
You must be signed in to change notification settings - Fork 6
/
loadwords.php
105 lines (69 loc) · 1.91 KB
/
loadwords.php
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<?php
// dBase file
session_start();
include "dbConfig.php";
$DB = new DBConfig();
$DB -> config();
$dbhandle =$DB -> conn();
if (isset($_REQUEST['action'])) {
$action = $_REQUEST['action'];
switch ($action) {
case 'get_rows':
getRows();
break;
case 'row_count':
getRowCount();
break;
default;
break;
}
exit;
} else {
return false;
}
function getRowCount() {
$strSQL = "SELECT COUNT(*) FROM `words` ";
if(isset($_GET["arg1"]))
{
if($_GET["arg1"] !="")
$strSQL = "SELECT COUNT(*) FROM `words` WHERE `word` LIKE '".chr($_GET["arg1"])."%'";
}
$result = mysql_query($strSQL);
$count = mysql_fetch_row($result);
echo $count[0];
}
function getRows() {
$start_row = isset($_REQUEST['start'])?$_REQUEST['start']:0;
$start_row = 10 * (int)$start_row;
$employees = loadWords($start_row);
$formatted_employees = "<ul><li><h2>Words</h2><ul>" . formatData($employees) . "</ul></li></ul>";
echo $formatted_employees;
}
function loadWords($start_row = 0) {
$strSQL="";
$strSQL = "SELECT id,word FROM `words` ORDER BY id ASC LIMIT {$start_row}, 10";
if(isset($_GET["arg1"]))
{
if($_GET["arg1"] !="")
$strSQL = "SELECT id,word FROM `words` WHERE `word` LIKE '".chr($_GET["arg1"])."%' ORDER BY id ASC LIMIT {$start_row}, 10";
}
$result = mysql_query($strSQL);
$employees = array();
while ($row = mysql_fetch_assoc($result)) {
$employees[] = $row;
}
return $employees;
}
function formatData($data) {
$formatted = '';
foreach ($data as $dat) {
$formatted .= "<li><a href=meanings.php?wordid=".$dat['id']."&word=".$dat['word'].">". $dat ['word']."</li></a>";
}
return $formatted;
}
function er($data) {
echo "<pre>";
print_r($data);
echo "</pre>";
}
?>