Hello! Help solve the problem. As I understand it, it is fairly simple, but I'm only trying to figure out PHP.
The essence of the question / task: I have input fields in the form, which, depending on the conditions, can be up to 30. And they may not all be filled (i.e. 1-12, 14,15 with entries 13, 16 without , then again with records, etc.).
I process each field as follows:
// если заполнена первая кнопка if ($_POST['BT1_pair']) { if ( $_POST['distribution_board'] == 'ШР') $_POST['BT1_distribution'] = 'Р'.$_POST['BT1_distribution']; else if ( $_POST['distribution_board'] == 'MJ21V00' || $_POST['distribution_board'] == 'MJ22V00' || $_POST['distribution_board'] = 'MJ23V00' ) { $_POST['BT1_distribution'] = 'ПК'.$_POST['BT1_distribution']; } // добавляем к индексу № $_POST['distribution_board'] = $_POST['block'].''.$_POST['distribution_board']; //$_POST['code_connections'] = $_POST['btn_two_index'].'.'.$_POST['btn_two'].':'.$_POST['btn_one_index'].'.'.$_POST['btn_one']; // формируем шифр $_POST['code_btn'] = $_POST['distribution_board'].'.'.$_POST['BT1_distribution'].'.'.$_POST['BT1_pair']; //делаем запись в базу mysqli_query($CONNECT, "INSERT INTO `GGS_btn` VALUES ('', '$_POST[index]', '1', '$_POST[distribution_board]', '$_POST[BT1_distribution]', '$_POST[BT1_pair]', '$_POST[code_btn]' )"); } So far I have written only for one button, but I understand that it is possible to make a cycle and to BT (BT1) increase the number to 30 and thus process all the fields. But until he could realize it, there is not enough knowledge ...
I would be extremely grateful for the help in the implementation of the task!
for($i=1;$i<=30;$i++) { if ($_POST['BT'.$i.'_pair']) ... }In general, fields in the form wouldBT_pair[0], BT_pair[1], etc. And would you have at the entrance of the finished array - MikeVALUES ('', '$_POST[index]', '$i', '$_POST[distribution_board]', '$_POST[BT1_distribution]', '$_POST[BT1_pair]', '$_POST[code_btn]' )");- Vasily UK