Welcome Guest, Not a member yet? Register   Sign In
getting previous, current, and next data from database
#1

I'm beginner in CI4 and currently learning about database handling.

I want to make a phone display site, where user could select a phone, then check previous and next entry / model.

So I know about getResult() and how to show everything, and I know that getRow(##) could return specific row. There's also getNextRow() and getPreviousRow(), but I can't find the proper way of using it.
I'm not even sure how I could find the "current" index of item I'm browsing. Do I skipped some step on database handling? I can't use cheap trick like "item_ID - 1", because the ID is somewhat mixed up between brand (like Nokia, LG, iPhone, for example).
Reply
#2

Not tested but I believe it works like this.

PHP Code:
$query $db->query("YOUR QUERY");

$row $query->getRowArray();

$row $query->getFirstRow($row)
$row $query->getLastRow($row)
$row $query->getNextRow($row)
$row $query->getPreviousRow($row

Give that a try.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB