I would like to get more checkbox content into my database. It means that I have categories of php, java, html and css but I click on php and html, so it must be the two into in the same database that is within the database category.
It looks like this when I lie in the database:
$kategori = $_POST["kategori"];
How it looks when the user must select a category such as php and html to the database:
<input type="checkbox" name="kategori[]" value="<?php echo $tekst;?>"/>
<?php echo $tekst;?>
Right now when I put it into the database writes just "array" and nothing else even though I have selected two categories to the database.
How do I put multiple categories into the database same time?
say for example you have 2 checkbox:
<input type="checkbox" name="kategori[]" value="1"/>
<input type="checkbox" name="kategori[]" value="2"/>
so when you submit the form in the submit page the data in the variable is $_POST["kategori"] is structure as:
Array([0] => 1
[1] => 2
); //which you could see by executing the code print_r($_POST["kategori"]);
So in order to put it into the database you can change it into a comma seperated string and insert under a single field in the database table
$kategori = implode(",",$_POST["kategori"]); //which will give the output "1,2" when you do echo $kategori;
I hope this can be of some help
You want each check to have an unique id, you submit the form to the back-end and then you can check the value of each checked check in the check-box by referring to the ids.