Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

Extend my details page with Next & back

Explorer ,
Feb 13, 2009 Feb 13, 2009

Copy link to clipboard

Copied

Hi Guys,
Im not sure if i can do this and have tried with no success so far so thought I need to ask advice..

I have a page that displays a list and when an item in the list is picked your taken to the details page by using an URL Parimeter (id) The details pages takes the id and pulls a single record from the database and shows the info and pics needed and this works fine.

I wanted to add a next and back buttons to this details page but because the recordset on the page only pulls 1 record I dont have any records to scroll though using the next and back buttons and wondered how I could do this?

I can do it on a seperate page where I pull all the reocrds from the database and they scroll back and forth well but I want it all to be done on the same details page if possible?

Any and all thoughts are very welcome.
Thanks
Tag
TOPICS
Server side applications

Views

524
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 13, 2009 Feb 13, 2009

Copy link to clipboard

Copied

You would have to manually code the detail page as follows (I think):

1. Save the desired record in a session variable from the Master page.
2. Load the full recordset into the detail page (as you did on the master
page), and then step through all the records, loading them into an array.
3. Display the nth element of the array on the detail page, as specified by
the session variable.
4. Based on the total record count in the array, and the value of the
current record, show NEXT and PREVIOUS links as required.
5. Adjust the session variable by either plus or minus 1 at each click on
the NEXT or PREVIOUS links, respectively and then reload the page.

That would be how you would do it with server scripting alone. If you want
to delve into AJAX/Spry, you can do it client side, too. Your best bet
would be to ask that question on the Spry forum.

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
==================


"webstaffuk" <webforumsuser@macromedia.com> wrote in message
news:gn3c11$6u4$1@forums.macromedia.com...
> Hi Guys,
> Im not sure if i can do this and have tried with no success so far so
> thought
> I need to ask advice..
>
> I have a page that displays a list and when an item in the list is picked
> your
> taken to the details page by using an URL Parimeter (id) The details pages
> takes the id and pulls a single record from the database and shows the
> info and
> pics needed and this works fine.
>
> I wanted to add a next and back buttons to this details page but because
> the
> recordset on the page only pulls 1 record I dont have any records to
> scroll
> though using the next and back buttons and wondered how I could do this?
>
> I can do it on a seperate page where I pull all the reocrds from the
> database
> and they scroll back and forth well but I want it all to be done on the
> same
> details page if possible?
>
> Any and all thoughts are very welcome.
> Thanks
> Tag
>

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 13, 2009 Feb 13, 2009

Copy link to clipboard

Copied

Thanks for that Murry,

I get the basics of what your saying but am unsure how to do your step 2: Can you elaborate a little more on how you would step through the records and put them into an array and then display the nth element to begin with..

Im guessing something like a while loop until EOF?

Is there any built in functions in DW for doing this or am I going to have to hand code the building of the array?

Thanks again.
tag

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 13, 2009 Feb 13, 2009

Copy link to clipboard

Copied

webstaffuk wrote:
> I get the basics of what your saying but am unsure how to do your step 2: Can
> you elaborate a little more on how you would step through the records and put
> them into an array and then display the nth element to begin with..

Murray's on the right track, but I think his proposal is wasteful of
resources. This is my solution:

The detail page currently has a recordset that retrieves a single record
based on its ID.

To create the previous and next links, you need two more recordsets to
get the IDs before and after the current one. You don't say which server
model you're using, but this is how the SQL would look in MySQL to get
the previous ID:

SELECT id FROM mytable
WHERE id < URLvar
ORDER BY id DESC
LIMIT 1

Check the number of records retrieved. If no records, the current ID is
the first one, so the previous link should not be shown.

To get the next ID:

SELECT id FROM mytable
WHERE id > URLvar
ORDER BY id ASC
LIMIT 1

If no records are found, the current one is the highest, so the next
link should not be displayed.

--
David Powers, Adobe Community Expert
Author, "The Essential Guide to Dreamweaver CS4",
"PHP Solutions" & "PHP Object-Oriented Solutions"
http://foundationphp.com/

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 13, 2009 Feb 13, 2009

Copy link to clipboard

Copied

Thanks david,

I get the idea by using 2 new recordsets and clever sql to grab the upper Id's and lower Id's, Im using access database but the sql is similar.

When I click on my Next or Back links how do I get the fields on the page to show the data as its been mapped to the first recordset on the page and now im calling in 2 different New recordsets that are not bound on the page if you follow?

I would like to go with ajax as Murray suggests but Id like to get it running this way first.

If you could elaborate a little more id be very greatfull.
Thanks again for the support .
Tag

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 13, 2009 Feb 13, 2009

Copy link to clipboard

Copied

webstaffuk wrote:
> When I click on my Next or Back links how do I get the fields on the page to
> show the data as its been mapped to the first recordset on the page and now im
> calling in 2 different New recordsets that are not bound on the page if you
> follow?

Assuming your page is called detail.asp, the link should look something
like this:

<a href="detail.asp?id=<% ASP stuff to display previous id %>">Previous</a>

In other words, it just sends the ID of the record you want to display.
When the page reloads, that ID will be used to pick up the details of
the previous record. The two other recordsets will query the database
again to get the new previous and next IDs.

--
David Powers, Adobe Community Expert
Author, "The Essential Guide to Dreamweaver CS4",
"PHP Solutions" & "PHP Object-Oriented Solutions"
http://foundationphp.com/

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 13, 2009 Feb 13, 2009

Copy link to clipboard

Copied

Yes, I like that much better. Of couse, any such methods require a return
trip to the server, which would be avoided by the use of AJAX/Spry. But
that brings another level of sophistication into the picture....

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
==================


"David Powers" <david@example.com> wrote in message
news:gn3t3u$se1$1@forums.macromedia.com...
> webstaffuk wrote:
>> I get the basics of what your saying but am unsure how to do your step
>> 2: Can you elaborate a little more on how you would step through the
>> records and put them into an array and then display the nth element to
>> begin with..
>
> Murray's on the right track, but I think his proposal is wasteful of
> resources. This is my solution:
>
> The detail page currently has a recordset that retrieves a single record
> based on its ID.
>
> To create the previous and next links, you need two more recordsets to get
> the IDs before and after the current one. You don't say which server model
> you're using, but this is how the SQL would look in MySQL to get the
> previous ID:
>
> SELECT id FROM mytable
> WHERE id < URLvar
> ORDER BY id DESC
> LIMIT 1
>
> Check the number of records retrieved. If no records, the current ID is
> the first one, so the previous link should not be shown.
>
> To get the next ID:
>
> SELECT id FROM mytable
> WHERE id > URLvar
> ORDER BY id ASC
> LIMIT 1
>
> If no records are found, the current one is the highest, so the next link
> should not be displayed.
>
> --
> David Powers, Adobe Community Expert
> Author, "The Essential Guide to Dreamweaver CS4",
> "PHP Solutions" & "PHP Object-Oriented Solutions"
> http://foundationphp.com/

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 13, 2009 Feb 13, 2009

Copy link to clipboard

Copied

Murray *ACE* wrote:
> Yes, I like that much better. Of couse, any such methods require a
> return trip to the server, which would be avoided by the use of
> AJAX/Spry.

Ajax would also require a return trip to the server unless you store all
details of every record when the page is first loaded. That would be
extremely heavy on resources. Imagine getting details of 100 records
when the user might want to see only one or two.

--
David Powers, Adobe Community Expert
Author, "The Essential Guide to Dreamweaver CS4",
"PHP Solutions" & "PHP Object-Oriented Solutions"
http://foundationphp.com/

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 13, 2009 Feb 13, 2009

Copy link to clipboard

Copied

Thank you David that helps me see what you mean now and I think I will manage this now..

Much appreciated.
Tag

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 13, 2009 Feb 13, 2009

Copy link to clipboard

Copied

Juts a quick note to say thanks again David, I gave it a go and in under 5 mins had a solution thanks to your advice. :-)

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 14, 2009 Feb 14, 2009

Copy link to clipboard

Copied

webstaffuk wrote:
> Juts a quick note to say thanks again David, I gave it a go and in under 5 mins had a solution thanks to your advice. :-)

Great. Nice to know you could adapt it so quickly to ASP.

--
David Powers, Adobe Community Expert
Author, "The Essential Guide to Dreamweaver CS4",
"PHP Solutions" & "PHP Object-Oriented Solutions"
http://foundationphp.com/

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 16, 2009 Feb 16, 2009

Copy link to clipboard

Copied

LATEST

"David Powers" <david@example.com> wrote in message
news:gn3t3u$se1$1@forums.macromedia.com...
>> To create the previous and next links, you need two more recordsets to
> get the IDs before and after the current one. You don't say which server
> model you're using, but this is how the SQL would look in MySQL to get the
> previous ID:

I had to do this very thing recently for a mod I'm doing on a site. I did it
exactly the same way - I'm glad to know that I did it the way DP would do it
🙂


Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines