This topic is locked

Show Calculated Ids List Page

3/3/2013 4:44:09 AM
PHPRunner General questions
N
nimda author

Hi,
i have a table products with this fields: id (int, Primary key) - autonumber, countproductid - (int, calculated for list page), product name. I want to show how many records are shown on the list page of the products. As far as i know IDs are not reused when deleted because that is the way the databases are working. But i need to show if there are 5 records: 1,2,3,4,5 etc even if a user deletes an entry to show properly the IDs. In that way i created a countproductid field in the database to calculate it and want to show it in the list page. Here is the code and where i insert it.
'List page: After record processed' event:

$record["countproductid"] = $_SESSION["countproductid"];

$_SESSION["countproductid"]++;


and i reset every time the countproductid in the 'List page: Before display' event:

$_SESSION["countproductid"] = 1;


but this doesn't work.. Should i do anything else somewhere or is there any problem with the Query itself? Any suggestions would be great.
Thanks.

Sergey Kornilov admin 3/5/2013

Here is the article that explains how to achieve this:

http://www.asprunner.com/forums/topic/5614-how-to-rank-database-records/
SQL Query is not really relevant here.