14 Replies Latest reply on Nov 26, 2007 2:23 AM by (nik_c)

    how can I get the last / newest record of a table?

      Hi,

      I am developing an ecard app that has a create greeting page, a preview page with edit and send buttons and an edit page.
      I got he insert working, and on the preview page I created a master record page (displays all records), and delete all unecessary designs. Doing it this way also gives me the 'edit' button, so people are able to edit their page.

      How do I get only the last record displayed though? At the moment it loops through all records and displays them in sets of 10. I found the variable that holds the totla count of records ('$totalRows_rs7417_content1'), but how do I (re-)write the script so it ONLY diplays the last record?

      I need to get the ID of this record as I am writing this into the PARAMs of the object and embed tags of my message .swf (this picks up the ID and based on that sucks the greetings text out of the database via another php script.

      Also, from this page, how can I send an email to the sender (ie creator of the message) as well as the recipient? Both email addresses are in the databse so should be part of the erecord returned.

      Thanks,

      Nik
        • 1. Re: how can I get the last / newest record of a table?
          Günter Schenk Level 4
          Hi Nik,

          you´ll usually just need to add...

          ORDER BY ID DESC LIMIT 1

          ...to that query to display the last inserted record only

          Cheers,
          Günter Schenk
          Adobe Community Expert, Dreamweaver
          • 2. Re: how can I get the last / newest record of a table?
            Level 1
            Hi Guenther,

            Thanks, where would I need to append that?

            I am looking at teh php page and I see teh php script sections at the top:
            // Load the common classes
            // Load the required classes
            // Make unified connection variable
            // Filter
            // Sorter
            // Navigation
            // NeXTenesio3 Special List Recordset (not sure if that is stil;l active as I tried various things (none of which worked so far),

            Thanks,
            Regards,
            Nik
            • 3. Re: how can I get the last / newest record of a table?
              Level 1
              Also, I am just looking in the old Kollektion extension: there was the possibility to 'Send email' and to insert this into a page. Does that still exist with the ADDT?

              I need to send out an email that contains a link in thsi format:
              http://www.jdgcsfiles.com/_ecards/view.php?ID_cnt=12

              which is going to be the link to the ecard the user has created (ID_cnt being the record ID of the greeting.

              Thanks,

              Nik
              • 4. Re: how can I get the last / newest record of a table?
                Level 1
                The email behaviour is of course still there! Silly me.
                Nik
                • 5. Re: how can I get the last / newest record of a table?
                  Günter Schenk Level 4
                  Hi Nik,

                  --------
                  Thanks, where would I need to append that?
                  --------

                  OK, I see it´s an ADDT dynamic list, and in here we´d be having a problem with what I suggested -- the existing query already provides an "ORDER BY" and "LIMIT" clause, so what I suggested will most likely be conflicting with what´s already there.

                  However, if you just need to display the last inserted record in the list and nothing else, creating a non-ADDT list would be much easier IMHO, also because you can add the "ORDER BY ID DESC LIMIT 1" to the basic "SELECT * FROM table_name etc etc etc" query without having to deal with such a conflict.

                  --------
                  The email behaviour is of course still there! Silly me
                  --------

                  see, that´s why I nowadays use to hold back my replies until folks answer their own questions, lol :-)

                  Cheers,
                  Günter Schenk
                  Adobe Community Expert, Dreamweaver
                  • 6. Re: how can I get the last / newest record of a table?
                    Level 1
                    OK, So how do I recreate what I got in a non-ADDT list? I am closwe to unsinstalling DWCS3 and ADDT and goign abckl to DWMX2004 and MX Kollektion. I am getting a bit desperate.

                    It also occurred to me just now that finding the last record that has been added *may-* notbe enough if the site gets used a lot by our executives (I am thinking of a situation where 2 or three peolpe create greetings at the same time and press submit and then getting each others messges rather than their own).

                    Do you think this is a valid concern?

                    Also, the email behaviour though still there ( ;) ), - I can't seemt o insert it on the page as it is looking for a insert, update or delete bahaviour on the page which of course I don't have. I am only displaying the a record (or at least want to) and don't need to update insert or delete on this page.

                    Is this possible

                    Thanks,

                    Nik
                    )no need to hold off with the answer to those ones BTW - don't think I'll answer these ones myself ;)
                    • 7. Re: how can I get the last / newest record of a table?
                      Level 1
                      BTW -

                      this is the start page of the app - if you are interested:

                      http://www.jdgcsfiles.com/_ecards/

                      I am using the variable that holds the total number of recrods to get feed into flash at the moment. not entirely correct, as it soemone should return to this page,after updating this might have changed while someone else submited their card.

                      Actually should I not look for the last record with the email that matches the senders as I search for the record on the preview page?

                      Thanks,...
                      Nik
                      • 8. Re: how can I get the last / newest record of a table?
                        Günter Schenk Level 4
                        -----
                        OK, So how do I recreate what I got in a non-ADDT list?
                        -----

                        well, when you´re just about to display one certain record, the term "list" is somewhat inappropriate anyway.

                        What you´d simply need to do IMHO, is using DW´s native functions to create the basic "SELECT * FROM table_name ORDEr BY ID DESC" query, add "LIMIT 1" manually, and display the desired "dynamic text" placeholders in 1 table cell -- don´t think there were any need for all the fancy stuff (sorting, filtering etc) provided by ADDT´s list, as it´s just 1 record.

                        ---------
                        It also occurred to me just now that finding the last record that has been added *may-* notbe enough if the site gets used a lot by our executives (I am thinking of a situation where 2 or three peolpe create greetings at the same time and press submit and then getting each others messges rather than their own).
                        ---------

                        in this case you might want to additionally store the respective executive´s "kt_login_id" session variable -- because it´s this unique "identifier" which should be used to show the last inserted record of the person who actually inserted it, means adding a "WHERE submitter_id" equals the session variable kt_login_id - clause to the query.

                        When creating a non-ADDT list that´s at some point based on detecting a user session, you´ll BTW need to insert at line 1

                        -------
                        I can't seemt o insert it on the page as it is looking for a insert, update or delete bahaviour on the page which of course I don't have
                        -------

                        please search these forums for several posts I made which explain my "use dummy table" approach that´s made for cases when you actually don´t have anything to insert/update/delete, but need "something" for ADDT´s send email behaviours.

                        Cheers,
                        Günter Schenk
                        Adobe Community Expert, Dreamweaver
                        • 9. Re: how can I get the last / newest record of a table?
                          Level 1
                          OK, this is getting very strange.
                          I thought so far that the Interakt sutie of code is cross platfrom concerning the browsers it works with.

                          But I am discovering that after developing using Firefox so far, it suddenly does not work in Internet explorer:

                          here is the URL:

                          http://www.jdgcsfiles.com/_ecards/

                          Filling in and clicking Create shoudl take you to this page:

                          http://www.jdgcsfiles.com/_ecards/masterDetail.php

                          but using Internet Explorer it doesn't.

                          the form uses this line to organise the submission:


                          and this is the submit buttons code:


                          Does anyone have any ideas why this could be?

                          Nik
                          • 10. Re: how can I get the last / newest record of a table?
                            Level 1
                            OK, I have disvered that actually the only computer on which this works is my development machine.

                            How this is possible is a mystery to me. I cannoty see a connection ebtween the sourcefiles on one hand and the browser through which I am looking at the files on the other hand?

                            How can my Friefox browser know where to go to, but my IE browswer can't - on my machine. And on no other machine?

                            Spooky.

                            Nik
                            • 11. Re: how can I get the last / newest record of a table?
                              Günter Schenk Level 4
                              Hi Nik,

                              --------
                              Filling in and clicking Create shoudl take you to this page:

                              http://www.jdgcsfiles.com/_ecards/masterDetail.php

                              but using Internet Explorer it doesn't.
                              --------

                              works fine for me (IE 7)

                              Cheers,
                              Günter Schenk
                              Adobe Community Expert, Dreamweaver
                              • 12. Re: how can I get the last / newest record of a table?
                                Level 1
                                that's becaused I fixed it already!
                                I think I must have changed the page inadvertedly so it wasn't working anymore, but my browser served (at least bits of it) from a cache! once i closed and opened it it didn't work anymore like in all the others, and I rebuild the page.

                                Now it's back to working.

                                But I still need to solve the db record problem, so I can get to work on sending out the emails, etc.

                                Thanks for your help!! (so far, sure there'll be more!)

                                Nik C
                                • 13. Re: how can I get the last / newest record of a table?
                                  Level 1
                                  OK, I have come a bit further with this eCard thing now. I have rewritten the preview page simply using the Dynamic Text feature from the Server Behaviour drop down. That seems to work very well.

                                  There are now a few things I still need to do:

                                  - Attach an email trigger to the words 'Click here to send' - I am still not sure: do I need to create a dummy form to make this work?

                                  - Create an EDIT button/link, that allows the users to edit their message. Again, do I have to create a form to make this work, as when I am trying to insert an edit record behaviour I am being told that there is no form.

                                  Is this the issue of dealing with dummy tables and forms you mentioned earlier?

                                  Thanks, Guenther, for your patience.

                                  Nik C
                                  • 14. Re: how can I get the last / newest record of a table?
                                    Level 1
                                    URGENT!

                                    I am ALMOST finished with this web app! But there is especially one thing I can't seem to get to work!

                                    I need to attach a 'click here to send' button to an email trigger to email the ecard link to the recipient and also cc'ed to the sender. I set up the trigger on the page but HOW DO I LINK IT TO A piece of text??

                                    Do I use an anchore like click here

                                    Do you know how I could do this?

                                    Thanks!
                                    Nik