I have three tables and I want to put them together and display them to the user, how can I do this using the WordPress functions?
INSERT THE DATA ON THE BANK:
function cadastra_experiencia($nome, $email, $experiencia){ //INSERE OS DADOS NO BANCO
global $wpdb;
$table = 'experiencia';
$data = array(
'nome' => $nome,
'email' => $email,
'exp' => $experiencia,
);
$updated = $wpdb->insert( $table, $data );
if ( ! $updated ) {
$wpbb->print_error();
}
}
function cadastra_alturapesotipo($altura, $peso, $estilo){
//INSERE OS DADOS NO BANCO
global $wpdb;
$table = 'alturapesoestilo';
$data = array(
'altura' => $altura,
'peso' => $peso,
'estilo' => $estilo,
);
$updated = $wpdb->insert( $table, $data );
if ( ! $updated ) {
$wpbb->print_error();
}
}
BANK:
CREATE TABLE EXPERIENCIA(
exp_pri INT NOT NULL AUTO_INCREMENT,
nome VARCHAR(150),
email VARCHAR(50),
exp VARCHAR(100),
PRIMARY KEY(exp_pri)
);
CREATE TABLE PRANCHA(
prancha_pri INT NOT NULL AUTO_INCREMENT,
tamanho_prancha VARCHAR(8),
meio_prancha VARCHAR(2),
litragem_prancha VARCHAR(3),
PRIMARY KEY (prancha_pri)
);
CREATE TABLE ALTURAPESOESTILO(
idAltPes INT NOT NULL AUTO_INCREMENT,
idExp INT,
idPrancha INT,
altura VARCHAR(4),
peso VARCHAR(3),
estilo VARCHAR(15),
primary key (idAltPes),
constraint fk_idExp foreign key (idExp) references EXPERIENCIA (exp_pri),
constraint fk_idPrancha foreign key (idPrancha) references PRANCHA (prancha_pri)
);
INNER JOIN:
SELECT EXP.exp,
AEP.altura,
AEP.peso,
AEP.estilo,
PRAN.tamanho_prancha,
PRAN.meio_prancha,
PRAN.litragem_prancha
FROM EXPERIENCIA AS EXP
INNER JOIN ALTURAPESOESTILO AS AEP ON
(EXP.exp_pri = AEP.idAltPes)
INNER JOIN PRANCHA AS PRAN ON
(PRAN.prancha_pri = AEP.idAltPes)
I put it in SQLFiddle for a better view: link
I want to display this inner join
to the user (text, alert, modal), any example / path how to do this is welcome.
I took a look at the WordPress Codex, but without much success.