1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Adding another item/row on a set

Discussion in 'Databases' started by neilfurry, Aug 25, 2016.

  1. #1
    Hello Mate,

    I just want to ask some advise on how to do this functionality.

    How do i insert another item/s to an already inserted set. for for example

    cleaningID section cost estimateID
    ----------------------------------------------------------------
    1 1 150.00 E08202016-01
    2 2 50.00 E08202016-01

    I want another item to be added with the same estimateID
    so, i want to add:

    cleaningID section cost estimateID
    ----------------------------------------------------------------
    3 1 70.00 E08202016-01

    In the first glance it is easy to do as i will just need to use insert on this but the twist is, when i need to edit a set it will populate this three rows on my form, but then when i need to add another item from editing it will create another estimateID.

    How do i implement adding an item to an already created id

    Thank you
     
    neilfurry, Aug 25, 2016 IP
  2. sarahk

    sarahk iTamer Staff

    Messages:
    28,500
    Likes Received:
    4,460
    Best Answers:
    123
    Trophy Points:
    665
    #2
    The problem is with your form rather than the database I think.
    Look at your hidden variables and what you are actually inserting.
     
    sarahk, Aug 25, 2016 IP
  3. neilfurry

    neilfurry Active Member

    Messages:
    55
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    63
    #3
    I think what i need is sort of array push functionality... which is used to add an item to an array... my problem is how can this be applied in mysql...
     
    neilfurry, Aug 25, 2016 IP
  4. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #4
    The database is not the problem. The form is, as @sarahk stated. When pulling information for editing, also pull the estimateID - then, when pushing back/saving the edit, adding a new row, save it with the estimateID - if no estimateID is provided, create a new ID. It is not that hard, but it all depends on how the update/insert form(s) are created.

    Normally, you would have a list of existing rows in an overview, and then, you'd chose to either edit an existing row, update an existing offer (estimateID) or create a new estimate alltogether. Depending on what you pick to do, the form you use will update accordingly. So for editing an existing row, you just do an update on the selected row(s) (based on existing ID, not the estimateID) - if you want to add to an already existing estimateID, you would need to do an insert, but base that insert on the already existing estimateID. For creating a new estimateID, that is fairly easy, by just using what you have now.
     
    PoPSiCLe, Aug 25, 2016 IP