0
I am developing a new PHP ordering system that works as follows:
- The user does upload requests, which are stored in a Mysql table called requests;
- After uploading, the user can change the status of those imported applications by script in PHP that do the table update requests;
- Each change is saved through a Trigger in a table called logs;
- Orders have a unique and unique number that does not repeat.
I could create a link in the order number, for example, that invokes a modal, and within this modal display the changes that are in the table logs only that order number clicked?
display of Mysql data on the page:
$result = mysqli_query($connect, "SELECT * FROM `pedidos`");
echo "<div style='height: 70%;'><table border='1' id='pedidos' class='table table-responsive'>
<tr>
<th><input type='checkbox' name='select-all' id='select-all' /></th>
<th>Data de emissão</th>
<th>EMS</th>
<th>Pedido do cliente</th>
<th>Cliente</th>
<th>Valor do pedido</th>
<th>Status</th>
<th>Nota Fiscal</th>
</tr>";
while($row = mysqli_fetch_array($result))
{
echo "</ul>";
echo "<tr>";
echo "<td><input name='checkbox[]' type='checkbox' value=" . $row['id'] . "></td>";
echo "<td>" . $row['emissaoPed'] . "</td>";
echo "<td><a data-toggle='modal' href='#myModal'>" . $row['nPedido'] . "</a></td>";
echo "<td>" . $row['NrPedido'] . "</td>";
echo "<td>" . $row['nomeAbrev'] . "</td>";
echo "<td>" . $row['vlr'] . "</td>";
echo "<td>" . $row['status'] . "</td>";
echo "</tr>";
}
echo "</table>";
echo "</form></div>";
I made the following query to bring the request by order number:
$result = mysqli_query($connect, "SELECT * FROM `logs` where nPedido IN (34366)");
However, I do not know how to replace the order number as defined in query by the order number clicked.
Yes, I could. But to help you do that we’ll need more information: how are these records being displayed with PHP? What is the HTML structure for this? Do you know how to work with modals? Do you know how AJAX requests work?
– Woss
Olá Anderson! Added the question how data is displayed on the page! With the modals I read the documentation of the bootstrap, and it doesn’t seem very complex. Now regarding AJAX, I know that it makes it possible to make requests, both of scripts and PHP, but I have no idea how to make the php script to pull the data.
– Rick Parapinski
Rick, I’m not in time to draft an answer right now, but I did a functional example (link). See if you can understand how it works. I’ll draft the answer as soon as possible if no one answers before.
– Woss
Anderson, thanks for the example. I read a little bit more about ajax and how it handles data. I read some more and added the code to the page, and inside the modal divide, I placed the columns, which display the changes. But I don’t know how to define the nPedido as the user clicks. (The current one is fixed in the query).
– Rick Parapinski