Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Senior Coder
    Join Date
    May 2006
    Posts
    1,873
    Thanks
    31
    Thanked 4 Times in 4 Posts

    INSERT/UPDATE in WHILE loop difficulty

    Hi,
    I have 2 table joined, the client table and the services table.
    ( common field is client_id)

    A user can have only 3 service table rows.

    When the user looks at their services I like the form to be populated
    with existing data, or blank if the none or less that three rows are used.

    The form can have three 3 "panels" for each row.

    When hitting the submit button the script should UPDATE the row(s)
    that are existing and INSERT the row(s) that are not - max 3 rows.

    In the past, I separated the write-new from the update functions, but
    it would be better is this instance to be more "compact".

    I have been trying to work with a do while loop but got
    into a mess !!

    Is this possible ?

    Any ideas on achieving this ?

    Many thanks.
    If you want to attract and keep more clients, then offer great customer support.

    Support-Focus.com. automates the process and gives you a trust seal to place on your website.
    I recommend that you at least take the 30 day free trial.

  2. #2
    Senior Coder benanamen's Avatar
    Join Date
    Oct 2015
    Posts
    1,624
    Thanks
    11
    Thanked 164 Times in 159 Posts
    Look into INSERT IGNORE
    To save time, lets just assume I am almost never wrong.

    The XY Problem
    The XY problem is asking about your attempted solution (X) rather than your actual problem (Y). This leads to enormous amounts of wasted time and energy, both on the part of people asking for help, and on the part of those providing help.

    Make A Donation https://www.paypal.me/KevinRubio


 

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •