I have a question form with several questions, after the respond person has a save button that sends the answers and questions to the salva.php
Follow the get (url):
salva.php?
data_cadastro=2017-07-08
& cli_id = 1
& cli_nome=OTACIO+BARBOSA
& cli_end=RUA+A
& cli_tel=3333333333
& cli_data_nasc=1900-01-01
& cli_cidade=TESTE
& cli_estado=MG
& usu_id = 1
& 1=3
& 2=0
& 3=1
& 4=5
& 5=3
& 6=1
& 7=0
& 8=3
& 9=0
& 10=1
& 11=5
& 12=5
& 13=5
& 14=3
& 15=3
& 16=0
& 17=0
& 18=1
& 19=1
& 20=0
& 21=0
& 22=1
& 23=3
& 24=5
I need to save this data in the responses table:
resp_fixa_id
resp_fixa_id_perg
resp_fixa_id_cliente
resp_fixa_id_resp
resp_fixa_data_cad
Being as follows:
resp_fixa_id = data_cadastro
resp_fixa_id_perg = ( é o sequencial mmostrado de 1 a 24 )
resp_fixa_id_cliente = cli_id
resp_fixa_id_resp = é o que vem na frente do sequencial (1 = 3 (no caso seria o 3))
resp_fixa_data_cad = data_cadastro
That is, you need to leave it as follows to insert in the database:
INSERT INTO resposta (resp_fixa_id,resp_fixa_id_perg,resp_fixa_id_cliente,resp_fixa_id_resp,resp_fixa_data_cad)
VALUES('NULL','1','1','3','2017-07-08');
INSERT INTO resposta (resp_fixa_id,resp_fixa_id_perg,resp_fixa_id_cliente,resp_fixa_id_resp,resp_fixa_data_cad)
VALUES('NULL','2','1','0','2017-07-08');
INSERT INTO resposta (resp_fixa_id,resp_fixa_id_perg,resp_fixa_id_cliente,resp_fixa_id_resp,resp_fixa_data_cad)
VALUES('NULL','2','1','1','2017-07-08');
How could you do this conversion?
Note: This sequence is the number of questions on the screen that the person answered, but it is not fico, it can be more or even that amount.
Complement:
$total_de_perguntas = count($_POST)-9;
$VarLoja = $_POST['loja'];
$VarDataCadastro = $_POST['data_cadastro'];
$VarUsuario = $_POST['usuario'];
$VarNome = $_POST['cli_nome'];
$VarEndereco = $_POST['cli_end'];
$VarTelefone = $_POST['cli_tel'];
$VarDataNascimento = $_POST['cli_data_nasc'];
$VarCidade = $_POST['cli_cidade'];
$VarEstado = $_POST['cli_estado'];
$iniciaPerguntas = 1;
while($iniciaPerguntas <= $total_de_perguntas) {
$VarRespostas = $_POST["$iniciaPerguntas"];
$VarString = '$Query'.$iniciaPerguntas = "INSERT INTO sug_respostas (resp_fixa_id,
resp_fixa_id_perg,
resp_fixa_id_cliente,
resp_fixa_id_usu,
resp_fixa_id_resp,
resp_fixa_data)
VALUES (NULL,
'$iniciaPerguntas',
'$VarNewNumClientes',
'$VarUsuario',
'$VarRespostas',
'$VarDataCadastro');";
$Result = '$Result'.$iniciaPerguntas = $conn->query($VarString);
$iniciaPerguntas++;
}
Notice: Undefined index: in C: \ xampp \ htdocs \ systems \ general_administration \ suggestions \ salva.php on line 28
Notice: Undefined index: in C: \ xampp \ htdocs \ systems \ general_administration \ suggestions \ salva.php on line 28
Notice: Undefined index: in C: \ xampp \ htdocs \ systems \ general_administration \ suggestions \ salva.php on line 28
Notice: Undefined index: in C: \ xampp \ htdocs \ systems \ general_administration \ suggestions \ salva.php on line 28