1
I’m trying to make a code for inventory control using PHP. Each time the user uses the program, the user 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 take 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 am not able to catch this employee by the value of Submit, since this is outside the 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 right way, is there any other way? Remembering that the employee does not need to be inside the loop, since at each use all lines will have only one employee, but the other fields change.
MODIFIED: The code I am doing is for product output control. In it I have the registration below:
As I complete the registration and click add, I add in the list below:
The problem is: Let’s imagine that we are registering the 3rd employee, and using only this code:
$sql = "SELECT * FROM controle_saida WHERE DATE(data_saida)=CURDATE()";
It won’t be enough to bring in just one employee table, and it will eventually bring in all the records that were made today, including the other 2 employees. With this what I want is: I’m filling out Eduardo’s product registration, I just want to call his name on the next page to print out a report, and I’m not able to do it.
I don’t understand.. Does each employee have to have a button on it? And then fill it in
– Hiago Souza
In fact, you select an employee and from that fill out the rest of the report. It is a product output control, IE, as a page for printing will come out, it is not convenient to be done with multiple employees at the same time.
– Felipe
$func = $Row[run]; echo $func; it prints the desired value ?
– Hiago Souza
This works, but as I am dealing with a table, it will bring all the values of the table once it is inside the while. Even if it was only an employee, Felipe for example, in echo would bring "Felipe Felipe Felipe Felipe"
– Felipe
And what is the value you want, I’m sorry but I still don’t understand?
– Hiago Souza
The right thing would be to explain what makes this system of yours, or how you want it to work, and only then could you expose the problem.
– Edilson
I thought I had explained enough. I’ve already edited my question.
– Felipe