foreign key problems when selecting items

0

Well, I'm trying to select all items from two separate listings, but without success, I'm using:

  

Query

select t*, d.id as id_discvinculada from textos as t join disciplinas as d on t.id_discvinculada = d.id
  

Function

function listagemTextos($conexao){
    $textos = array();
    $resultado = mysqli_query($conexao, "select t*, d.nome_disciplina as id_discvinculada from textos as t join disciplinas as d on t.id_discvinculada = d.id");
    while($texto = mysqli_fetch_assoc($resultado)){
        array_push($textos, $texto);
    }
    return $textos;
}
  

Function call

<?php

$textos = listagemTextos($conexao);

foreach ($textos as $texto){
    ?>

    <div>
        <div>
            <h4><?= $texto["titulo"] ?></h4>
            <label><?= $texto["id_discvinculada"] ?></label>
            <ul>
                <span>Opções</span>
                <li>Alterar</li>
                <li><a href="logicas/logica-remover_texto.php?id=<?= $texto['id']?>">Remove</a></li>
            </ul>
        </div>
        <div>
            <?= $texto["texto"] ?>
        </div>
    </div>

    <?php
}
  

Disciplines

  

Texts

  

Warning

Warning
: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in
C:\xampp\htdocs\dev_port\historia\logicas\banco_textos.php
on line
7

How do I add the Foreign Key, and use it so that I can display the items correctly in the function call?

    
asked by anonymous 10.07.2017 / 21:40

1 answer

2

Try to change your query to this:

select t.*, d.nome_disciplina as id_discvinculada from textos t
join disciplinas d on t.id_discvinculada = d.id
    
10.07.2017 / 21:42