0
Database:
DROP DATABASE IF EXISTS mydb;
CREATE DATABASE IF NOT EXISTS mydb;
USE mydb;
CREATE TABLE clientes (
cod_clientes INT UNSIGNED NOT NULL AUTO_INCREMENT,
nome VARCHAR (20) NOT NULL,
PRIMARY KEY (cod_clientes)
) ENGINE = innodb;
CREATE TABLE erros(
cod_erros INT UNSIGNED NOT NULL AUTO_INCREMENT,
nome_erro VARCHAR (150) NOT NULL,
solucao VARCHAR (255) NOT NULL,
data_ocorrencia DATE,
sistema VARCHAR (30) NOT NULL,
PRIMARY KEY (cod_erros)
) ENGINE = innodb;
CREATE TABLE funcionarios (
cod_funcionarios INT UNSIGNED NOT NULL AUTO_INCREMENT,
login VARCHAR(15) NOT NULL,
email VARCHAR(50) NOT NULL,
senha VARCHAR(15) NOT NULL,
cpf VARCHAR (11) NOT NULL UNIQUE,
PRIMARY KEY (cod_funcionarios),
Fk_Clientes INT UNSIGNED,
Fk_Erros INT UNSIGNED,
FOREIGN KEY Fk_Clientes (Fk_Clientes) REFERENCES clientes (cod_clientes) ON UPDATE CASCADE ON DELETE RESTRICT,
FOREIGN KEY Fk_Erros (Fk_erros) REFERENCES erros (cod_erros) ON UPDATE CASCADE ON DELETE RESTRICT
) ENGINE = innodb;
View:
CREATE VIEW VIEW_LISTA_ERROS AS SELECT nome AS Cliente,
nome_erro AS Erro, solucao AS Solucao,
data_ocorrencia AS Data, sistema AS Sistema
FROM erros, clientes;
select *from VIEW_LISTA_ERROS;
Part of PHP code where I’m trying to insert:
if ($row == 0) {
$query = "insert into erros(nome_erro,solucao,data_ocorrencia,sistema)
values('{$nome_erro}', ('{$solucao}'), ('{$data}'), '{$sistema}')";
$query2 = "insert into clientes(nome)
values('{$nome_cliente}'";
mysqli_query(conexao(), $query);
mysqli_query(conexao(), $query2);
header('location: paginaConsulta.php');
}
}
the answer helped you? If yes, try to schedule it to help other colleagues.
– user148170