-1
Good afternoon guys, trying since yesterday and not getting, next I have these two tables in the bank, when I soon save this session $_SESSION['username'] = $username;
but they need to give a select on the registered pets and they return all the content of the bank and not the user has registered
CREATE TABLE `novo_pet` (
`id_novopet_cod` INT(11) NOT NULL AUTO_INCREMENT,
`nome_animal` VARCHAR(100) NOT NULL,
`raca_animal` VARCHAR(100) NOT NULL,
`idade_animal` INT(2) NULL DEFAULT NULL,
`cor_animal` VARCHAR(100) NOT NULL,
`especie_animal` VARCHAR(100) NOT NULL,
`porte_animal` VARCHAR(100) NOT NULL,
`sexo_animal` VARCHAR(5) NOT NULL,
`proprietario_animal` VARCHAR(100) NOT NULL,
`caracteristica_animal` VARCHAR(500) NOT NULL,
`telefone_animal` VARCHAR(100) NOT NULL,
`image` TEXT NOT NULL,
`situacao_animal` TEXT NOT NULL,
PRIMARY KEY (`id_novopet_cod`)
)
COLLATE='latin1_swedish_ci'
ENGINE=MyISAM
AUTO_INCREMENT=4
;
CREATE TABLE `usuario` (
`id_usuario_cod` int NOT NULL PRIMARY KEY AUTO_INCREMENT ,
`username` varchar(50) NOT NULL,
`email` varchar(50) NOT NULL,
`senha` varchar(50) NOT NULL,
`telefone` varchar (12) not null,
`sexo_usuario` varchar (10) not null,
`trn_date` datetime NOT NULL
);
?php
$sql = "select * from novo_pet ";
$result = mysqli_query($conn, $sql);
if(mysqli_num_rows($result)){
while($row = mysqli_fetch_assoc($result)){
if anyone can help me in this matter, I thank you for your help. ?>
Well there are several points in your code that need to be improved, 1° how do you know who registered each pet ? you need to add a Foreign key to your pets table referencing the user. according to your select do not have Where, ie you are bringing all the data from the database
– Marcos Brinner