ckrudelux Posted October 9, 2009 Share Posted October 9, 2009 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 More sharing options...
shadowayex Posted October 9, 2009 Share Posted October 9, 2009 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 More sharing options...
justsomeguy Posted October 9, 2009 Share Posted October 9, 2009 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 More sharing options...
ckrudelux Posted October 10, 2009 Author Share Posted October 10, 2009 You need to get the list of items and figure out which position the one you're interested in falls into.Solved it but thanks anyway Link to comment Share on other sites More sharing options...
PravinBhat Posted October 12, 2009 Share Posted October 12, 2009 connect to my sqlset the query.aftr that$res=Query$i=0;j=1;while($r=mysql_fetch_row($res)){$i++;//display row appropriately...if(i%4==0){print $j;$j++;}}//while endsThats it .........Try !! Link to comment Share on other sites More sharing options...
shadowayex Posted October 13, 2009 Share Posted October 13, 2009 He said he already solved the problem =/ Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.