I made a list of checkboxes that upon click would be sent to database. Every time I submit data the value is 0. If I try and convert the value of the array to string, I get string to array error.
<form method="post">
<?php
global $wpdb;
$Result = $wpdb->get_results("SELECT Product1 FROM A");
foreach($Result as $Thing1) {
echo '<input type="checkbox" name="Num1[]" />' . $Thing1->Product1 . "<br />";
}
$Age = $_POST['Num1'];
if($_POST['btn']) {
if(!empty($Age)) {
foreach($Age as $id) {
// this enters in the value as 0 idk why
$wpdb->query("INSERT INTO A(Product1) VALUES('$id');");
}
}
}
?>
<button name="btn">Submit</button>
</form>