nickelus Posted November 25, 2009 Share Posted November 25, 2009 is it possible to use an non-paged list such as an array of record_ids and a set of next /prev buttons to navigate through rows in a mysql db to display an individuals record ex. client records Quote Link to comment Share on other sites More sharing options...
JAY6390 Posted November 25, 2009 Share Posted November 25, 2009 Could you give a little more explanation and an example of some kind? Quote Link to comment Share on other sites More sharing options...
nickelus Posted November 25, 2009 Author Share Posted November 25, 2009 i have a table that holds client records with a pri key of account _id. i am attempting to use an array of all of the account_ids to shift to the next or previous id in the array depending on which button was pressed Quote Link to comment Share on other sites More sharing options...
JAY6390 Posted November 25, 2009 Share Posted November 25, 2009 You would need to do three queries SELECT * FROM table_name WHERE `id` = 'id here' SELECT `id` FROM table_name WHERE `id` > 'id here' ORDER BY `id` ASC LIMIT 1 SELECT `id` FROM table_name WHERE `id` < 'id here' ORDER BY `id` DESC LIMIT 1 That will get you your three records you need. The first gets the actual info of the currently showing record, the second gets the next record's id and the third gets the previous records id You will need to check that each result produces a row via error handling. Then assign links that contain those id's in the GET params to pass them back to the script to show the next/prev item Quote Link to comment Share on other sites More sharing options...
nickelus Posted November 25, 2009 Author Share Posted November 25, 2009 can i get the array first then use the next() & prev() in a conditional way in combination with the buttons. i want to do something different than pagination. so maybe as the pointer increases or decreases use the value to hold the place Quote Link to comment Share on other sites More sharing options...
nickelus Posted November 25, 2009 Author Share Posted November 25, 2009 i should mention that the array is already in a particular order which would eliminate the last option and also the reason i want to pass the array through the buttons Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.