OnClick MySQL database update

I run a PHP/MySQL web database. I would like to include a tickbox on a dynamically generated page so that users can track whether the item represented on that page is within their collection. After a JavaScript onclick trigger, this should then:

1, update the database similar to below:

INSERT INTO collection (user_id, item_id)

VALUES ($_SESSION[id], $_GET[id])

... where $_SESSION[id] is the ID of the logged on user, 1 indicates it is in their collection and $_GET[id] is the item that is being marked as part of the user's collection.

2. If the tickbox is already ticked and they wish to remove it from their collection it would instead do:

DELETE FROM collection WHERE user_id = $_SESSION[id] AND item_id = $_GET[id] LIMIT 1

3. The tickbox image should automatically update to ticked or unticked status according to whether it is in the user's collection after the onclick trigger.

IMPORTANT: This should be done without reloading the page (presumably by AJAX.)

Examples of similar functionality can be found at Amazon (you can add items to your wishlist in this way) or at

Access to our web code will be made available to successful bidder via Plesk.

The rest of this page is already written - this is simply adding the above functionality. I will create a suitable MySQL table in advance.

Skills: AJAX, Javascript, MySQL, PHP

See more: javascript onclick php insert mysql, onclick update database, ajax onclick mysql update, onclick update mysql ajax, insert database user onclick mysql ajax, javascript onclick insert database, javascript onclick mysql update, php onclick update database, onclick update database php, update database javascript, javascript onclick database, php onclick update, onclick javascript update table ajax, javascript update mysql onclick ajax, javascript update mysql database, ajax onclick mysql, update mysql database javascript, onclick image database mysql, javascript onclick update, web database, update mysql, Database collection, update status php mysql, update status code, update delete amazon

About the Employer:
( 1 review ) London, United Kingdom

Project ID: #1290049