C
C
Chesterfield252021-07-11 09:27:29
PHP
Chesterfield25, 2021-07-11 09:27:29

How to make multiple entries in the database?

How to make multiple entries in the database? In simple terms, I need to add several records to one table, which will have a different section and category, functional like a store. The section and category comes with a select drop down list.

My entry form

<form action="" method="post"> <div class="form-group"> <small>MicroWallets Name</small> <select class="form-select" aria-label="Default select example"> <option selected>MicroWallets</option> <?php foreach ($type as $value) { ?> <option value="<?=$value->id ?>"><?=$value->title ?></option> <?php } ?> </select> </div> <div class="form-group"> <small>Category Name</small> <select class="form-select" aria-label="Default select example"> <option selected>Category</option> <?php foreach ($category as $value) { ?> <option value="<?=$value->id ?>"><?=$value->title ?></option> <?php } ?> </select> </div> <div class="form-group"> <small>Title</small> <input type="text" class="form-control" name="title"> </div> <div class="form-group"> <small>Url</small> <input type="text" class="form-control" name="url"> </div> <div class="form-group"> <small>Time</small> <input type="text" class="form-control" name="time"> </div> <div class="modal-footer"> <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button> <button type="submit" class="btn btn-primary" name="add">Save</button> </div> </form>


DB query

$title = $_POST['name']; $url = $_POST['url']; $get_id_type = $_GET['id']; $select_1 = $_POST['select_1']; $select_2 = $_POST['select_2']; $sql = ("INSERT INTO xf_type (title, url,select_1, select_2) VALUES (?,?,?,?)");

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Localhost, 2021-07-11
@selo

I will answer here
<select multiple="multiple" name="select_1[]">
If you need to style in a list and checkboxes (click Result), other options in multiselect js

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question