disable a php button by with database status

Asked

Viewed 186 times

-2

how do I create a php button that when it has some status in the database it is disabled, when no database status is enabled

  • Button in PHP? Implementing a PHP graphical interface or this button is HTML?

  • 1

    Welcome to Stackoverflow please refer to the following link https://answall.com/help/how-to-ask

  • You can create a bool in the database (true or false) and when it is false, you will check with ajax and disable it, when it is true, you enable. Do with Ajax.

1 answer

1


I suppose you’re using PHP mixed with HTML, so it would look 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 PHP code from HTML, search a little about PHP templates.

Browser other questions tagged

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