I'm passing three parameter to URL: &p1=eventID
, &p2=firstItem
, &p3=numberOfItems
. first parameter is a column of table. second parameter is the first item that I'm looking for. Third parameter says pick how many items after firstItem
.
for example in first query user send &p1=1
, &p2=0
, &p3=20
. Therefore, I need first 20 items of list.
Next time if user sends &p1=1
, &p2=21
, &p3=20
, then I should pass second 20 items (from item 21 to item 41).
PHP file is able to get parameters. currently, I'm using following string to query into database:
public function getPlaceList($eventId, $firstItem, $numberOfItems) {
$records = array();
$query = "select * from {$this->TB_ACT_PLACES} where eventid={$eventId}";
...
}
Result is a long list of items. If I add LIMIT 20 at the end of string, then since I'm not using Token then result always is same.
how to change the query in a way that meets my requirement? any suggestion would be appreciated. Thanks
=> update:
I can get the whole list of items and then select from my first item to last item via for(;;)
loop. But I want to know is it possible to do similar thing via sql? I guess this way is more efficient way.