How to publish content through a database by clicking a checkbox?

There is a form in which are recorded the values from the database, there is a button that adds a new input. There are two problems. Don't know how to make so that added an empty input, and not with the first value from the database. The second problem is that I can not understand how to publish these number checkbox. They are displayed on another page using the database, but if the checkbox is not pressed then they are not displayed. The principle is this.
<?php foreach($numbers as $number):
 if($number->user_id == $_SESSION['user_id']):
?>
 <div class="form-group" id="phone">
 <div class="controls">
 <input type="checkbox" name="publish_phone[]" id="publish" > <label>Publish field</label>
 <input type="text" class="form-control" name="numbers[]" id="number" value="<?php echo $number->number; ?>">
</div>
</div>
<?php
endif;
 endforeach; ?>

$(document)
 .ready(function () {
 const variant = $('#phone')
.clone(true);
 const variant2 = $('#emails')
.clone(true);
$('#add')
 .click(function () {
$(variant)
.clone(true)
.appendTo('#variants')
.fadeIn('slow')
.focus();
});
$('#add2')
 .click(function () {
$(variant2)
.clone(true)
.appendTo('#variants2')
.fadeIn('slow')
.focus();

});
 });
March 19th 20 at 09:13
0 answer

Find more questions by tags HTMLjQueryJavaScriptPHP