Jorge Reyes
2010-02-18 18:02:58 UTC
Hi everyone, first im sorry because i dont know how to explain my
issue so i have to put a fragment of my code which is written in php
and mysql, my goal is transfer this querys to sybase, hope im not
disturbing and somebody can help me:
$pageNo = $json->{'pageInfo'}->{'pageNum'};
$pageSize = 10;
$sql = "select count(*) as cnt from orders";
$handle = mysql_query($sql);
$row = mysql_fetch_object($handle);
$totalRec = $row->cnt;
//make sure pageNo is inbound
if($pageNo<1||$pageNo>ceil(($totalRec/$pageSize))){
$pageNo = 1;
}
//page index starts with 1 instead of 0
$sql = "select * from orders limit " . ($pageNo - 1)*$pageSize . ",
" . $pageSize;
This last query is the problem, as you can see this allows me to
paging the results increasing the $pageNo so i can ask for page 1 with
10 results, then page 2 with the next 10 and so on. How can i make
this with T-SQL?
Thanks in advanced.
issue so i have to put a fragment of my code which is written in php
and mysql, my goal is transfer this querys to sybase, hope im not
disturbing and somebody can help me:
$pageNo = $json->{'pageInfo'}->{'pageNum'};
$pageSize = 10;
$sql = "select count(*) as cnt from orders";
$handle = mysql_query($sql);
$row = mysql_fetch_object($handle);
$totalRec = $row->cnt;
//make sure pageNo is inbound
if($pageNo<1||$pageNo>ceil(($totalRec/$pageSize))){
$pageNo = 1;
}
//page index starts with 1 instead of 0
$sql = "select * from orders limit " . ($pageNo - 1)*$pageSize . ",
" . $pageSize;
This last query is the problem, as you can see this allows me to
paging the results increasing the $pageNo so i can ask for page 1 with
10 results, then page 2 with the next 10 and so on. How can i make
this with T-SQL?
Thanks in advanced.