
Сообщение от Schtrich
запрос идет к этому файлу ajax.php:
| PHP | 1
| ajax.php?action=getBase |
|
там и ищите по вашей базе нужные данные.
|
Что то я этот поиск не могу вкурить)
| 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
106
107
108
| <?php
require_once ('lib/DbSimple/Generic.php');
$db = new DbSimple_Generic();
$db = DbSimple_Generic::connect('mysql://user:12345@localhost/ipgolang?charset=utf8');
mysql_query("SET NAMES 'utf8'");
if(isset($_GET['action']) && $_GET['action']=='xls') {
ini_set('display_errors', 1);
xls();
}
function countRec($fname,$tname,$where) {
$sql = "SELECT ru($fru) FROM $tru $where";
$result = runSQL($sql);
while ($row = mysql_fetch_array($records)) {
return $row[0];
$page = $_POST['page'];
$rp = $_POST['rp'];
if (!$page)
$page = 1;
if (!$rp)
$rp = 10;
$start = (($page - 1) * $rp);
//$sortname = $_POST['sortname'];
//$sortorder = $_POST['sortorder'];
$sortname = false;
$sortorder = false;
if (!$sortname)
$sortname = 't1.key';
if (!$sortorder)
$sortorder = 'asc';
$sort = "ORDER BY $sortname $sortorder";
$where = " ";
$items = $db->selectPage($total, "select t1.key,t1.ru,t2.kz as kz from lang_ru t1
left join lang_kz t2 on t1.key=t2.key $where
$sort limit ?d,?d", $start, $rp);
echo mysql_error();
$rows = array();
foreach ($items as $key => $item)
{
$rows[] = array('id' => $key, 'cell' => array_values($item));
}
$data['page'] = $page;
$data['total'] = $total;
$data['records'] = sizeof($items);
$data['rows'] = $rows;
//echo mysql_error();
$sql = "SELECT key,ru $where $sort $limit";
$result = runSQL($sql);
$total = countRec('ru',$where);
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . "GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
//header("Content-type: text/x-json");
echo json_encode($data);
$json = "";
$json .= "{\n";
$json .= "page: $page,\n";
$json .= "total: $total,\n";
$json .= "rows: [";
$rc = false;
/*while ($row = mysql_fetch_array($total))*/ {
if ($rc) $json .= ",";
$json .= "\n{";
$json .= "key:'".$row['id']."',";
$json .= "cell:['".$row['id']."','".$row['ru']."'";
$json .= "}";
$rc = true;
}
$json .= "]\n";
$json .= "}";
echo $json;
function xls() {
global $db;
$items = $db->selectPage($total, "select t1.key,t1.ru,t2.kz as kz from lang_ru t1
left join lang_kz t2 on t1.key=t2.key ", $start, $rp);
$xls = "<html><table border=1 style='border-collapse:collapse'><tr><td>ключ</td><td>Русский</td><td>Казахский</td></tr>";
foreach($items as $row)
$xls.="<tr><td>".$row['key']."</td><td>".$row['ru']."</td><td>".$row['kz']."</td></tr>";
$xls.="</table></html>";
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . "GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
header("Content-Disposition: attachment;filename=list.xls");
header("Content-Transfer-Encoding: binary ");
echo $xls;
} |
|
Вроде как я понял надо добавить json после того как таблица вся подгружается а дальше потеря у меня)
Добавлено через 12 минут

Сообщение от LitrianAs
Что то я этот поиск не могу вкурить)
| 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
| <?php
require_once ('lib/DbSimple/Generic.php');
$db = new DbSimple_Generic();
$db = DbSimple_Generic::connect('mysql://user:12345@localhost/ipgolang?charset=utf8');
mysql_query("SET NAMES 'utf8'");
if(isset($_GET['action']) && $_GET['action']=='xls') {
ini_set('display_errors', 1);
xls();
}
$page = $_POST['page'];
$rp = $_POST['rp'];
if (!$page)
$page = 1;
if (!$rp)
$rp = 10;
$start = (($page - 1) * $rp);
//$sortname = $_POST['sortname'];
//$sortorder = $_POST['sortorder'];
$sortname = false;
$sortorder = false;
if (!$sortname)
$sortname = 't1.key';
if (!$sortorder)
$sortorder = 'asc';
$sort = "ORDER BY $sortname $sortorder";
$where = " ";
$items = $db->selectPage($total, "select t1.key,t1.ru,t2.kz as kz from lang_ru t1
left join lang_kz t2 on t1.key=t2.key $where
$sort limit ?d,?d", $start, $rp);
echo mysql_error();
$rows = array();
foreach ($items as $key => $item)
{
$rows[] = array('id' => $key, 'cell' => array_values($item));
}
$data['page'] = $page;
$data['total'] = $total;
$data['records'] = sizeof($items);
$data['rows'] = $rows;
//echo mysql_error();
$sql = "SELECT key,ru $where $sort $limit";
$result = runSQL($sql);
$total = countRec('ru',$where);
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . "GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
//header("Content-type: text/x-json");
echo json_encode($data);
$json = "";
$json .= "{\n";
$json .= "page: $page,\n";
$json .= "total: $total,\n";
$json .= "rows: [";
$rc = false;
/*while ($row = mysql_fetch_array($total))*/ {
if ($rc) $json .= ",";
$json .= "\n{";
$json .= "key:'".$row['id']."',";
$json .= "cell:['".$row['id']."','".$row['ru']."'";
$json .= "}";
$rc = true;
}
$json .= "]\n";
$json .= "}";
echo $json;
function xls() {
global $db;
$items = $db->selectPage($total, "select t1.key,t1.ru,t2.kz as kz from lang_ru t1
left join lang_kz t2 on t1.key=t2.key ", $start, $rp);
$xls = "<html><table border=1 style='border-collapse:collapse'><tr><td>ключ</td><td>Русский</td><td>Казахский</td></tr>";
foreach($items as $row)
$xls.="<tr><td>".$row['key']."</td><td>".$row['ru']."</td><td>".$row['kz']."</td></tr>";
$xls.="</table></html>";
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . "GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
header("Content-Disposition: attachment;filename=list.xls");
header("Content-Transfer-Encoding: binary ");
echo $xls;
} |
|
Вроде как я понял надо добавить json после того как таблица вся подгружается а дальше потеря у меня)
|
забыл кое что удалить
Добавлено через 1 час 12 минут

Сообщение от Schtrich
запрос идет к этому файлу ajax.php:
| PHP | 1
| ajax.php?action=getBase |
|
там и ищите по вашей базе нужные данные.
|
Вот по образцу пытался сделать но что то не хочет
| 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
106
107
108
109
110
111
112
113
114
115
116
117
118
| <?
require_once ('lib/DbSimple/Generic.php');
function runSQL($rsql){
$db = new DbSimple_Generic();
$db = $db->connect("mysql://root:1q2w3e4r5t@localhost/ipgolang");
mysql_query("SET NAMES 'utf8'");
if(isset($_GET['action']) && $_GET['action']=='xls') {
ini_set('display_errors', 1);
xls();
}}
function countRec($fname,$tname,$where) {
$sql = "SELECT count($fname) FROM $tname $where";
$result = runSQL($sql);
while ($row = mysql_fetch_array($result)) {
return $row[0];
}
}
$page = $_POST['page'];
$rp = $_POST['rp'];
if (!$page)
$page = 1;
if (!$rp)
$rp = 10;
$start = (($page - 1) * $rp);
//$sortname = $_POST['sortname'];
//$sortorder = $_POST['sortorder'];
$sortname = false;
$sortorder = false;
if (!$sortname)
$sortname = 't1.key';
if (!$sortorder)
$sortorder = 'asc';
$sort = "ORDER BY $sortname $sortorder";
$where = " ";
$items = $db->selectPage($total, "select t1.key,t1.ru,t2.ru as kz from lang_ru t1
left join lang_kz t2 on t1.key=t2.key $where
$sort limit ?d,?d", $start, $rp);
echo mysql_error();
$rows = array();
foreach ($items as $key => $item)
{
$rows[] = array('id' => $key, 'cell' => array_values($item));
}
echo $_POST['lang_ru'];
$data['page'] = $page;
$data['total'] = $total;
$data['records'] = sizeof($items);
$data['rows'] = $rows;
//echo mysql_error();
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . "GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
//header("Content-type: text/x-json");
echo json_encode($data);
$limit = "LIMIT $start, $rp";
$sql = "select t1.key,t1.ru,t2.ru as kz from lang_ru t1
left join lang_kz t2 on t1.key=t2.key $where $sort $limit";
$result = runSQL($sql);
$total = countRec('ru','kz',$where);
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT" );
header("Last-Modified: " . gmdate( "D, d M Y H:i:s" ) . "GMT" );
header("Cache-Control: no-cache, must-revalidate" );
header("Pragma: no-cache" );
header("Content-type: text/x-json");
$json = "";
$json .= "{\n";
$json .= "page: $page,\n";
$json .= "total: $total,\n";
$json .= "rows: [";
$rc = false;
while ($row = mysql_fetch_array($result)) {
if ($rc) $json .= ",";
$json .= "\n{";
$json .= "id:'".$row['id']."',";
$json .= "cell:['".$row['id']."','".$row['ru']."'";
$json .= ",'".addslashes($row['kz'])."'";
$json .= "}";
$rc = true;
}
$json .= "]\n";
$json .= "}";
echo $json;
function xls() {
global $db;
$items = $db->selectPage($total, "select t1.key,t1.ru,t2.ru as kz from lang_ru t1
left join lang_kz t2 on t1.key=t2.key ", $start, $rp);
$xls = "<html><table border=1 style='border-collapse:collapse'><tr><td>ключ</td><td>Русский</td><td>Казахский</td></tr>";
foreach($items as $row)
$xls.="<tr><td>".$row['key']."</td><td>".$row['ru']."</td><td>".$row['kz']."</td></tr>";
$xls.="</table></html>";
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . "GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
header("Content-Disposition: attachment;filename=list.xls");
header("Content-Transfer-Encoding: binary ");
echo $xls;
} |
|
0
|