6 Replies Latest reply on Apr 30, 2008 10:43 AM by (mombazaa)

    last record id onto query string

      I have used

      $lastinsteredid = $tNG->getPrimaryKeyValue()

      in my transaction to get the primary key of the record i have just inserted. i wish to use this id so i can view this record when i reach the next page.

      please could you tell me how i can get the $lastinsteredid variable onto the end of the query string of the next page.

      i know how to set the page to redirect to, just not how to add my variable to the query string.
        • 1. Re: last record id onto query string
          Günter Schenk Level 4
          Hi Chris,

          assuming your Primary Key column is named "id", you can add the Primary Key value of the newly inserted record to ADDT´s Trigger_Default_Redirect by simply referencing it as Dynamic Data, e.g.:

          "nextpage.php?id={id}"

          On that page you should construct the query like this:

          "SELECT * FROM table_name WHERE id" equals the URL parameter "id"

          Cheers,
          Günter Schenk
          Adobe Community Expert, Dreamweaver
          • 2. Re: last record id onto query string
            Level 1
            Hi Günter , thankyou for all the help.

            I did as you said.

            i recive the message "Column unique_advert_id" is not part of the current transaction, this is my primary key column, which is auto increment.

            as the primary key is auto increment i dont see how to include unique_advert_id in the insert query.

            Any thoughts on what i am doing wrong ?
            • 3. Re: last record id onto query string
              Günter Schenk Level 4
              Hi Chris,

              do you see something like this in the page code:

              $ins_tablename->setPrimaryKey("unique_advert_id", "NUMERIC_TYPE");

              ?

              Cheers,
              Günter Schenk
              Adobe Community Expert, Dreamweaver
              • 4. Re: last record id onto query string
                Level 1
                Hi Günter

                $ins_tablename->setPrimaryKey("unique_advert_id", "NUMERIC_TYPE");

                is not in my code.it was a custom form,i dont know if this makes a difference.
                • 5. Re: last record id onto query string
                  Günter Schenk Level 4
                  Hi Chris,

                  indeed, this makes a difference. If you would have built the form with ADDT´s Insert Record wizard, the aforementioned code would be there.

                  Alright, let´s forget about that and come back to the main issue "how to retrieve the last inserted record´s id in a query string" -- here´s a pretty easy way to do that:

                  "SELECT * FROM tablename ORDER BY unique_advert_id DESC LIMIT 1"

                  You will have to add the "LIMIT 1" part manually, as DW´s recordset builder can´t handle that.

                  Works ?

                  Cheers,
                  Günter Schenk
                  Adobe Community Expert, Dreamweaver
                  • 6. Re: last record id onto query string
                    Hi Günter,
                    I've been following closely the above correspondense to find if it could help me resolve a similar issue but to no avail.
                    I have addt list/form with an autoincrement ID column. I wish to have a second column on the list whose value will be a fixed string concartenated to the current ID, e.g. 'ACL-currentID'. The list should look something like below after clicking insert on the associated form:
                    IDColumn SecondColumn
                    1 ACL-1
                    2 ACL-2
                    3 ACL-3

                    Regards,
                    Mombazaa