disable a button in php by with status in database [closed]

-2

How do I create a button in php that when it has some status in the database it is disabled, when it does not have status in the database it is Enabled

    
asked by anonymous 11.07.2018 / 15:01

1 answer

1

I suppose you're using PHP mixed with HTML, so it looks something like this:

<?php

    // restante do código onde você pega o status no banco e guarda na variável $status_banco, por exemplo

    $status_botao = $status_banco == true ? "" : "disabled";

    // seta a propriedade 'disabled' do botão de acordo com o status
    print "<button ".$status_botao."> Botão </button>";
?>

However, the ideal is to completely separate the PHP code from the HTML, search a little about PHP templates.

    
11.07.2018 / 16:24