I have a question about updating data in a field in my sql database. Basically im storing numbers in a field called "items", they are stored as comma seperated values, so for example;
22, 34, 65,
Currently I have to manually enter this, but I want to be able to add values to that field or remove values by using html tick boxes, the html code I made looks like;
<form action="" method="post"> Item 1 <input type="checkbox" name="item" value="1"> <br> Item 2 <input type="checkbox" name="item" value="2"> <br> Item 3 <input type="checkbox" name="item" value="3"> </form>
So basically if the value;
appears in the database, I want to be able to add a number to that sequence or remove a number by ticking or unticking the html tick boxe. An example would be if the field contained;
and I ticked the box with the value '2' then it would look like;
if I then unticked box value '3', it would edit the field to;
The sql code I use to insert the value currently is
<? session_start(); $sql ="UPDATE pics SET item='".$_POST['item']."' WHERE id = '".$_POST['idnum']."'"; @mysql_query($sql, $connection) or die(mysql_error()); exit; ?>
Is this possible? I think it is by using explode.
Any help or pointers would be very helpful.
Thanks in advance