if to show button or text

Asked

Viewed 37 times

0

    <?php

echo '


<table border=1>
<tr>
<th>ID Pergunta</th>
<th>Pergunta</th>
<th>Responder</th>
</tr>
'
;
include ("ligabd.php");//CONECTAR A BD
$sql="SELECT * from pedido WHERE ID_pr=".$_SESSION['ID'];
$sql1="SELECT * from resposta";

$resultado = mysql_query($sql);
while ($sql = mysql_fetch_array($resultado)) {

    echo '
    <tr>
    <td><form method="post" action="resposta.php" class="login">
    <input type="text" name="pergunta_id" id="pergunta_id" value= ' ;?> <?php echo $sql['ID']; ?> <?php echo ' > </td>
    <td>'.$sql['pergunta'].'</td>
    <td>  ';
    if (!isset($sql1['resposta'])!=""){
echo '<button type="submit" class="login-button">Responder</button>
</td>
</tr>';
}
else echo 'Pergunta Respondida';
}
    echo '</table>';
?>

Good morning, I have a doubt in this code, I want the if show me a button if the record of the answer is clean.
For example, I have a question like in the following image:

inserir a descrição da imagem aqui

if already answered appeared "Question Answered", and if not answered appeared the button

1 answer

0

Trade the isset for Empty:

if (empty($sql1['resposta'])){
//mostra botão
}else{
//pergunta respondida
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.