Activate and deactivate if from button

-1

Is it possible to activate and deactivate an if from a button? what I need is relatively easy .. although I do not get it ... well let's go to the topic what I want is simply that when I press a button I show the contents of an if any suggestion ??

<button type="button" name="button"></button>
@if()
<table>
  <tr>
    <td>contenido1</td><td>contenido2</td>
  </tr>
</table>
@endif
    
asked by Lendy Rodriguez Silva 12.12.2018 в 16:12
source

1 answer

1

Here is a small example with PHP :

<?php
    $flag = $_GET['flag'];
?>

<!DOCTYPE html>
<html lang="es">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>

<?php

if ($flag == 1) {

    echo '<a href="?flag=0"><button>Activar</button></a>';

else {

    echo '<a href="?flag=1"><button>Desactivar</button></a>';

}


?>

</body>
</html>
    
answered by 12.12.2018 / 16:31
source