Using a while
repeat structure, I want to send predefined data.
I'll try to show.
Database: Name: (joao, gabriel, vitor) mode: (0,0,0)
pagina1.php
<?php
session_start();
include_once("config.php");
?>
<?php
$sql = $db->query("SELECT nome,modo FROM banco_de_dados");
?>
<?php
while($dados = $sql->fetch_array()){
$nome = $dados['nome'];
$modo = $dados['modo'];
$_SESSION['nome_id'.$num] = $nome;
$num++;
?>
<center>
NOME: <?php
echo $nome;
?> |
<?php
echo $modo;
?> |
<a href="pagina2.php" role="button">ON//OFF</a><br>
</center>
<?php
}
?>
page2.php
<?php
session_start();
require_once 'pagina1.php';
$sql_up = "UPDATE bando_de_dados SET modo = ('1') WHERE nome = '$nome'" ;
$up = mysqli_query($db, $sql_up);
?>
When you click on on//off
, it changes from 0
to 1
. (It will change from 1 to 1, depending on the click)