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.

UPDATE with ADD

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

  1. #1
    Hello,

    I need some help here please.

    i have form inserting rows to database. this forms contains table based on cloning row.. so basically when i add new row it will add the values to database but when i retrieve data it will populate the rows to table then i will be able to add new row of data and update the exisiting data simultaneously. im using loop on my script..

    so when the loop finds a row that exist, it will just update the content of that row and if not found it will add the new item to database.

    Im not sure how to implement this using loop, can you give me an enlightenment?
    an example perhaps.

    Thank you
     
    neilfurry, Aug 31, 2016 IP
  2. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #2
    Well, if you have an existing row in the dataset, that row should have a unique ID from the database - which you will use to update said row. If it's new data, there will be no unique ID, and you'll just insert a new row. Just check for said ID (posted for instance via a hidden form-field, defaulting to something like "new_row_<insert counter>" if no ID is found)
     
    PoPSiCLe, Aug 31, 2016 IP