/    Sign up×
Community /Pin to ProfileBookmark

PHP/MYSQL updating issue

Here is the issue.
I have two databases/tables, 1 database table holds data for PAGES and the 2nd database table holds ARTICLES for that page. They are connected by THE ID field in the PAGES to the PAGEID in the ARTICLES.

I am using a series of check boxes to display the current pages from the PAGES table. This gives the user the ability to check off the pages they don’t want to keep and check the ones they want to keep.

Originally I was just going to run a query to delete them all and than insert the checked ones since the checkboxes are coming over in an array called pages[]. It just seemed easier to do that. But now the issue is by deleting them I am removing the articles from that page since it will assign and new ID to the PAGE entry. I hope that makes sense. Here is the basic structure of the tables I am using…

PAGES
ID
PAGE
PAGEORDER… as so on!!

ARTICLES
ID
PAGEID
ARTICLE… as so on!!

In the ARTICLES PAGEID is equal to the ID field in PAGES

What is the easiest way to update these fields using the checkbox format. Keeping in mind the ones they deselect will be deleted and the ones they select that haven’t been added yet will be added. Of course the ones that already exist will not be touched. Not sure how to update this easily.

The easy way would of course be to add, remove, update pages per a regular input field but I would prefer to use check boxes to display this.

Any help would be greatly appreciated. Thank you.

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @lincolnway spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...