I'm creating a page where some information will be uploaded, and that information will be transferred to a database and displayed on that same page, as follows:
As highlighted in blue, I have created a list with options that the user can choose x actions and change the displayed data.
But my main question is: how to exclude a row from the database, using the checkbox?
I tried several tutorials, but all without success.
On the page, I used these codes to import, store, and display the data:
<?php
if ($_FILES[csv][size] > 0) {
//get the csv file
$file = $_FILES[csv][tmp_name];
$handle = fopen($file,"r");
//loop through the csv file and insert into database
do {
if ($data[0]) {
mysqli_query($connect, "INSERT INTO 'pedidos' ('emissaoPed', 'nPedido', 'pedCliente', 'nomeAbrev', 'vlr', 'status') VALUES
(
'".addslashes($data[0])."',
'".addslashes($data[1])."',
'".addslashes($data[2])."',
'".addslashes($data[3])."',
'".addslashes($data[4])."',
'".addslashes($data[5])."'
)
");
}
} while ($data = fgetcsv($handle,1000,",","'"));
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Import a CSV File with PHP & MySQL</title>
</head>
<body>
<?php if (!empty($_GET[success])) { echo "<b>Your file has been imported.</b><br><br>"; } //generic success notice ?>
<form action="" method="post" enctype="multipart/form-data" name="form1" id="form1">
Choose your file: <br />
<input name="csv" type="file" id="csv" />
<input type="submit" name="Submit" value="Submit" />
</form>
<form action="" method="post" enctype="multipart/form-data" name="form2" id="form2">
<label>Selecione o status:</label>
<select name="changePed">
<option value="separacao">Em Separação</option>
<option value="cancelado">Cancelado</option>
<option value="faturado">Faturado</option>
<option value="exp">Expedido</option>
</select>
<input type="submit" value="Alterar">
</form>
<?php
$result = mysqli_query($connect, "SELECT * FROM 'pedidos'");
echo "<table border='1'>
<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>
</tr>";
while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td><input name='checkbox[]' type='checkbox'></td>";
echo "<td>" . $row['emissaoPed'] . "</td>";
echo "<td>" . $row['nPedido'] . "</td>";
echo "<td>" . $row['pedCliente'] . "</td>";
echo "<td>" . $row['nomeAbrev'] . "</td>";
echo "<td>" . $row['vlr'] . "</td>";
echo "<td>" . $row['status'] . "</td>";
echo "</tr>";
}
echo "</table>";
?>