Edit similar fields in codeigniter

Asked

Viewed 135 times

0

Imagine the following situation: Registered in a database several phones of a single establishment (local_1, +55 xx xxxx-xxxX; local_1, +55 xx xxxx-xxxY; ...);

The problem: Allow the user to edit these various phones (this includes add and remove) and save in the database this.

I figured of listing the phones and in case a change occurs, clear the database the old phones and add everything again (the modification)

Any suggestions to help me?

1 answer

1

I assume you have an establishment table and a telephone table, correct?

I recommend making this so that your data are (minimally) normalized.

After you have these two tables, you will be able to determine through a unique identifier for each phone which phone record you are effectively editing or removing, through a surrogate key or any other key you consider relevant ( ddd+number? ).

Possession of this unique identifier, it is not necessary to remove all other phones, but to change only the phone identified by this value.

  • then, my table is constituted in [ID - DDD - PHONE - COMPANY], to add these phone numbers, I use a jquery that allows me to duplicate the fields, ie, a company owns 0 or more phones. What I want to do is allow the deletion of any of the phones, also enable editing of any of the phones and adding new ones

Browser other questions tagged

You are not signed in. Login or sign up in order to post.