返回列表 發帖

請問extjs 排序問題不正常

本帖最後由 awelkije 於 2010-6-7 16:55 編輯

我的id為 1,2,3跑到第二頁去了 請問該如何解決呢
我的用的extjs版本是2.2


檢查你的排序方式,如果是在 client 端做的,檢查 JavaScript,如果是在 server 端做的,檢查 SQL 語法。
To infinity and beyond!

TOP

這是我的server端處理的代碼
<?php

require("config.php");
require("conn.php");
$line=50;
$limit=$_POST['limit'];
$start=$_POST['start'];
//$start=25;
$title=$_POST['title'];
//$limit=$_GET['limit'];
//$start=$_GET['start'];
//sleep(200);
//$title=iconv( "UTF-8", "gb2312//IGNORE" ,$title);
setcookie("_start",$start);
if($title!=""){
$count=@mysql_query("select count(id) as count from customer_basic_information where name like '%$title%' or school like '%$title%'",$db);
}else{
$count=@mysql_query("select count(id) as count from customer_basic_information",$db);
}

$count_nu=@mysql_fetch_array($count);
$count_number=$count_nu['count'];
$i=0;
echo "{totalcount_number,results:[";
if($start+$limit>$count_number){
$limit=$limit-($start+$limit-$count_number);
}
if($title!=""){
$req=@mysql_query("select * from customer_basic_information where name like '%$title%' or school like '%$title%' order by id DESC limit $start,$limit",$db);
}else{
$req=@mysql_query("select * from customer_basic_information order by id DESC limit $start,$limit",$db);
}
//fields: ["id", "name", "tell", "email", "qq", "school", "spec", "home", "hometell","work"]
while($return=@mysql_fetch_array($req)){
$id=$return['id'];
$client_name=$return['client_name'];
$company_name=$return['company_name'];
$company_eng_name=$return['company_eng_name'];
$c_tel_a=$return['c_tel_a'];
$c_tel_b=$return['c_tel_b'];
$c_mobilephone=$return['c_mobilephone'];
$c_fax=$return['c_fax'];
$c_invoice_address=$return['c_invoice_address'];
$c_delivery_address=$return['c_delivery_address'];
$c_mailing_address=$return['c_mailing_address'];
$c_zip_code=$return['c_zip_code'];
$c_company_number=$return['c_company_number'];
$c_create_date=$return['c_create_date'];
$c_responsible_person=$return['c_responsible_person'];
$c_responsible_person_birthday=$return['c_responsible_person_birthday'];
$c_responsible_person_id=$return['c_responsible_person_id'];
$c_contact_person=$return['c_contact_person'];
$c_contact_person_birthday=$return['c_contact_person_birthday'];
$c_contact_person_person_id=$return['c_contact_person_person_id'];


echo "{
id: $id,
client_name: '$client_name',
company_name: '$company_name',
company_eng_name:'$company_eng_name',
c_tel_a: '$c_tel_a',
c_tel_b: '$c_tel_b',
c_mobilephone: '$c_mobilephone',
c_fax: '$c_fax',
c_invoice_address: '$c_invoice_address',
c_delivery_address: '$c_delivery_address',
c_mailing_address:'$c_mailing_address',
c_zip_code:'$c_zip_code',
c_company_number:'$c_company_number',
c_create_date:'$c_create_date',
c_responsible_person:'$c_responsible_person',
c_responsible_person_birthday:'$c_responsible_person_birthday',
c_responsible_person_id:'$c_responsible_person_id',
c_contact_person:'$c_contact_person',
c_contact_person_birthday:'$c_contact_person_birthday',
c_contact_person_person_id:'$c_contact_person_person_id'


}";
$i++;
if($i<$limit){echo ",";}

}
echo "]}";
?>

TOP

你的程式都沒有縮排啊

試著把 $start log 下來,看看傳來的值是否正確。
To infinity and beyond!

TOP

請問要如何用Firebug來debug呢
extjs新手

TOP

不是啦,我是說後端的 $start,你就用 php 把結果存下來,看看是否傳正確的值到後端
file_put_contents("log.txt", $start . "\n", FILE_APPEND);
To infinity and beyond!

TOP

可以用js的來做排序嗎
不用後端的

TOP

返回列表 回復 發帖