- This topic is empty.
-
AuthorPosts
-
July 29, 2011 at 5:33 pm #33714
stevendeeds
MemberHey doods, I’m not really sure how to accomplish my goal on this one.
Here’s the website I’m working on:
http://lostimagesofww2.com/photos/places/louisiana-maneuvers.phpThis section of the site, is following a WW2 soldier (amateur shutterbug) through his travels.
The sidebar with the links shows the places in order of his travels.At the bottom of each ‘place’ page, I would like their to be dynamic links that functions like: “ONWARD TO $next_place” and “BACK TO $prev_place”. Somehow it needs to _GET the current page, and then check that information against a list of links, determine the current pages position in that list, and output the item before and after it.
Obviously, these links can’t be sorted alpha or numerically, and I want a ‘dynamic’ solution that would be graceful if another ‘place’ is discovered, and added somewhere into the list. This will probably have to be database driven or function driven, but any ideas on structure and manipulation of data so that it does what i want?
This is way over my head. Any help would be great.
July 29, 2011 at 9:02 pm #84248ddliu
MemberFirst of all, the list of data should be sortable(e.g. by related time, or by place, or sorted by order which is maintained manually).
Take following list for example:
TABLE "links":
#id #time #place #disp_order
1 ... New York 3
2 ... Devizes 5
3 ... London 1
So when showing entry #2, it will be:
New York …
<< Prev is London Next is Devizes >>
For data retrieving:
#1. Get data entry of #1 New York($entry)
#2. Get prev entry:
SELECT id, place FROM links WHERE disp_order < $entry ORDER BY disp_order LIMIT 1
#3. Get next entry:
SELECT id, place FROM links WHERE disp_order > $entry ORDER BY disp_order DESC LIMIT 1
Hope it helps.
July 30, 2011 at 9:28 am #84265stevendeeds
MemberHey @ddliu , first of all, thanks for your time so far. I like that table structure, I think that will work well, but my question is, at what point in this process does php determine what page you’re on?
July 30, 2011 at 9:47 am #84267ddliu
MemberYou can pass id of the entry to PHP, and php will get the entry by id, and then prev entry and next entry.
July 30, 2011 at 10:05 am #84269stevendeeds
Member@ddliu So I still have to physically tell php what page it’s on?
July 31, 2011 at 1:06 am #84284ddliu
MemberSorry I don’t quite understand your problem.
Of cause in the page where you show the place, you should know it’s ID or something else so that you can fetch the place entry from DB.
-
AuthorPosts
- The forum ‘Back End’ is closed to new topics and replies.