6 replies
Hi,

i am writing a form which requires multilple pages, or two anyway. my first form is simple just entering name date and so on(job form), but once this is submitted i create an automatic id number and submit it into MySQL.

i then move to the next form which takes in other stuff such as reason, type (jobRecords) blahh blahhh. But my problem is i want this to be related to the previous entry in the job table by using the auto id number. But so far cannot work out how to add this auto id from the last form, either enter 2 entries which i dont want or the number is set to 0.

Any suggestions
#forms #multiple
  • Profile picture of the author ussher
    put the data from page 1 into one table and the data from page 2 into another table and add the insert_id of the primary key of table one into table to as a normal column.

    so
    insert into first_page (first_id, first_value1, first_value2)

    run the query and get the returned insert id, then pass it to the second form page as the parent id.

    So when you do the insert into page2
    insert into second_page (second_id, second_first_id, second_value1, second_value2)

    have a value for the primary key 'first_id' of the first table. in this case 'second_first_id'

    Then when you run queries join them.
    SELECT * FROM second_page s LEFT JOIN first_page f ON s.second_first_id = f.first_id

    Should work.
    Signature

    "Jamroom is a Profile Centric CMS system suitable as a development framework for building entire communities. Highly modular in concept. Suitable for enterprise level development teams or solo freelancers."

    - jamroom.net
    Download Jamroom free: Download
    {{ DiscussionBoard.errors[4587105].message }}
  • Profile picture of the author indiansareedesigns
    Banned
    [DELETED]
    {{ DiscussionBoard.errors[4587132].message }}
    • Profile picture of the author ussher
      Originally Posted by indiansareedesigns View Post

      Best way to buy any product is online shopping... Indian Saree Designs is the online shopping portal which provides you all latest Indian Wear with bollywood style, lehenga style, wedding wear and more.
      Oh, yeah, that too ^^. (forgot about the best way to buy saree designs, its really relivant.):confused:
      Signature

      "Jamroom is a Profile Centric CMS system suitable as a development framework for building entire communities. Highly modular in concept. Suitable for enterprise level development teams or solo freelancers."

      - jamroom.net
      Download Jamroom free: Download
      {{ DiscussionBoard.errors[4587149].message }}
    • Profile picture of the author SebastianJ
      Originally Posted by indiansareedesigns View Post

      Best way to buy any product is online shopping... Indian Saree Designs is the online shopping portal which provides you all latest Indian Wear with bollywood style, lehenga style, wedding wear and more.
      What the ... ?
      {{ DiscussionBoard.errors[4587346].message }}
  • Profile picture of the author lovenot
    Is the 2nd form accessible only when the 1st is completed? If so, store in session and submit after the 2nd page is submitted. Otherwise do validation and what ussher says.
    {{ DiscussionBoard.errors[4587708].message }}
  • Profile picture of the author ussher
    Another option is just to make it LOOK like its 2 pages.

    Have the full form html loaded when the page loads and hide the second half using css
    <div style="display:hidden" class="formpage">

    and have a button on the page that when you click it it hides the first part of the form and shows the next part. (I like jquery so in jquery) something like:
    <div onclick="$('.formpage').toggle();">Next Page >></div>

    clicking on it will hide the div is showing and show the div that is hidden.

    Thats another way to do it maybe.
    Signature

    "Jamroom is a Profile Centric CMS system suitable as a development framework for building entire communities. Highly modular in concept. Suitable for enterprise level development teams or solo freelancers."

    - jamroom.net
    Download Jamroom free: Download
    {{ DiscussionBoard.errors[4592622].message }}
    • Profile picture of the author Tashi Mortier
      Several ways to solve this problem have already been mentioned.

      I'd like to add one more. You can get the last mysql_insert_id() once you submitted the database entry.

      Save this id into the php session and then you can use it on the next form.

      There is only one drawback: This is not "multithread safe" meaning that if the user enters 2 jobs at the same time, the second form might get linked to the first id or vice versa.

      So if you don't need this functionality, integrate a check to see if there is already an ID in the session, and then tell the user to go complete the form first or cancel it (deleting the first entry in the database).

      You could also just save all the data from the first form in the session and then combine it with the data from the second form to get one clean entry.
      Signature

      Want to read my personal blog? Tashi Mortier

      {{ DiscussionBoard.errors[4607000].message }}

Trending Topics