How can multiple values from checkboxes be stored in a database in PHP?

When dealing with checkboxes in HTML forms, multiple values can be selected by the user. To store these multiple values in a database using PHP, you can serialize the array of selected values before storing it in a database column. This way, you can easily retrieve and unserialize the data when needed.

// Assume $selectedValues is an array of selected checkbox values
$serializedValues = serialize($selectedValues);

// Store $serializedValues in the database column
// Example SQL query: INSERT INTO table_name (checkbox_values) VALUES ('$serializedValues');