I'm trying to make a code for stock control using PHP. Each time the user uses the program, the program must select an employee and from there select the rest of the fields as needed.
This part of the code works perfectly:
<tr>
<td><?php echo $row[funcionario] ?></td>
<td><?php echo $row[origem] ?></td>
<td><?php echo $row[destino] ?></td>
<td><?php echo $row[quantidade] ?></td>
<td><?php echo $row[package] ?></td>
<td><?php echo $row[conteudo] ?></td>
<td><?php echo $row[sabor] ?></td>
<td><b><a onclick="excluiProduto(<?php echo $row[id_saida] ?>)" class="btn btn-sm btn-danger" id="deleta"><span class="glyphicon glyphicon-trash" aria-hidden="true"><span></a></td></b>
</tr>
<?php
}
$func = $row[funcionario];
echo $func;
?>
</table>
</div>
<div class="container">
<div style="padding-top: 20px" class=" center-block" >
<form method="GET" action="imprimirRel.php">
<button value="<?php echo $func ?>" type="submit" name="submit" class="btn btn-sm btn-info" style="<?php echo $mostraTabela ?>">Confirmar saída</button>
</form>
</div>
</div>
Now I'm trying to get this value and move to another page in order to print a report with the following code:
<?php
INCLUDE "conexao.php";
$func = $_GET['submit'];
echo $func; die;
$sql = "SELECT * FROM controle_saida WHERE DATE(data_saida)=CURDATE() AND funcionario='".$func."'";
//DATE(date)=CURDATE()
$result = mysqli_query($conexao, $sql);
if (mysqli_num_rows($result)==0){
$mostraTabela = "display:none";
}
else {
$mostraTabela = "";
}
?>
The problem is that I can not get this employee by the value of submit, since this is outside of mysqli_fetch_assoc. If I put in, it pulls all the values that will appear inside the while loop. I imagine you're not doing it the best, is there any other way to do it? Remembering that the employee does not need to be inside the loop, since with each use all the lines will have only one employee, but the other fields will change.
MODIFIED: The code I'm doing is for output control. In it I have the register below:
AsIcompletetheregistrationandclickonadd,Iaddinthelistbelow:
The problem is: Let's imagine that we are doing the registration of the 3rd employee, and using only this code:
$sql = "SELECT * FROM controle_saida WHERE DATE(data_saida)=CURDATE()";
It will not be enough to bring the table just from one employee, and will eventually bring in all the records that were made today, inclusive of the other 2 employees.
What I want is: I am filling Eduardo's product register, I want to just name him on the next page to print a report, and I can not do that.