Hello, I would like to know how I can use php to avoid adding the same item to a database on a save page that adds the names of subcategories if I update the browser.
Since I can not use the Unique in the subcategory table in the name field, this would make it impossible for me to use the same name if it is affiliated with another category.
Below are the two tables.
Category Category
CREATE TABLE IF NOT EXISTS 'categoria' (
'id' int(255) NOT NULL AUTO_INCREMENT,
'categoria_url' char(255) COLLATE utf8_unicode_ci NOT NULL,
'nome' char(255) COLLATE utf8_unicode_ci NOT NULL,
'modo' enum('UNICO','MULTIPLO') COLLATE utf8_unicode_ci NOT NULL DEFAULT 'UNICO',
'data' date NOT NULL,
PRIMARY KEY ('id'),
UNIQUE KEY 'categoriaUnica' ('categoria_url'),
UNIQUE KEY 'nomeUnico' ('nome'),
KEY 'colunasIndexadas' ('id','categoria_url')
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;
Table subcategory
CREATE TABLE IF NOT EXISTS 'subcategoria' (
'id' int(255) NOT NULL AUTO_INCREMENT,
'categoria_url' char(255) COLLATE utf8_unicode_ci NOT NULL,
'subcategoria_url' char(255) COLLATE utf8_unicode_ci NOT NULL,
'temporada' int(3) NOT NULL,
'nome' char(255) COLLATE utf8_unicode_ci NOT NULL,
'cat' int(255) NOT NULL,
'semana' enum('Selecionar Semana','Domingo','Segunda-Feira','Terca-Feira','Quarta-Feira','Quinta-Feira','Sexta-Feira','Sábado') COLLATE utf8_unicode_ci NOT NULL DEFAULT 'Selecionar Semana',
'ativadorOn' enum('ON','OFF') COLLATE utf8_unicode_ci NOT NULL DEFAULT 'OFF',
'sinopse' text COLLATE utf8_unicode_ci NOT NULL,
'status' enum('Completo','Incompleto','Andamento','Pausado','Lançamento') COLLATE utf8_unicode_ci NOT NULL DEFAULT 'Andamento',
'genero' varchar(255) COLLATE utf8_unicode_ci NOT NULL,
'genero_url' varchar(255) COLLATE utf8_unicode_ci NOT NULL,
'numeroMedias' int(255) NOT NULL DEFAULT '0',
'autor' char(20) COLLATE utf8_unicode_ci NOT NULL,
'acessos' int(255) NOT NULL,
'arquivo_nome' varchar(355) COLLATE utf8_unicode_ci NOT NULL,
'arquivo_tipo' varchar(100) COLLATE utf8_unicode_ci NOT NULL,
'arquivo_data_cad' date NOT NULL,
'arquivo_hora_cad' time NOT NULL,
PRIMARY KEY ('id'),
KEY 'colunasIndexadas' ('id','cat','categoria_url')
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;