Jump to content

Calculate Page Number


ckrudelux
 Share

Recommended Posts

Does any one have a good solution on how I would get the page number for a item.Say I have 16 items in my database every 4 item a new page starts. Seens I only want to get the item number 12 from the database I wont know which page it would be on couse the database don't tell me its item 12 out of 16?

Link to comment
Share on other sites

What do you mean it's on a different page?Databases don't have "pages." Things like phpMyAdmin sort them into pages to make it easier to view.I don't know if it'll help with what you're hoping to accomplish, but if you give each item a unique id (if you're using MySQL, set a field called id and give it the primary key and auto increment options, that's what I do), you can use the id to distinguish them. Technically speaking, you should already be doing this with any database.

Link to comment
Share on other sites

Say I have 16 items in my database every 4 item a new page starts. Seens I only want to get the item number 12 from the database I wont know which page it would be on couse the database don't tell me its item 12 out of 16?
You need to get the list of items and figure out which position the one you're interested in falls into.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...