Hello friends I am trying to make a table, for each item in the table it appears a <select>
and a submit
that will send data via POST
, as it is relative how many units will appear can not predict quantities. Unfortunately the way I did any submit sends the last one on the list and not their respective one.
Is it possible to do this? What mistakes did I make?
I'm thinking about redoing all the code since it seems like I did it the wrong way, however I'm a bit confused. Can anyone give me tips.
Here are some snippets of the code.
Body part of the table
$query="SELECT DISTINCT 'clientes'.'nome', 'ficha_de_moveis'.'id_controle' , 'ficha_de_moveis'.'valor-total-controle','ficha_de_moveis'.'datamontagem', 'ficha_de_moveis'.'status' from 'clientes' join 'ficha_de_moveis' on 'clientes'.'id_cliente' = 'ficha_de_moveis'.'id-cliente'";
$sql=mysqli_query($conn,$query);
while($row= mysqli_fetch_array($sql)){
$numero = $row['id_controle'];
$cliente = $row['nome'];
$sobrenome = $row['sobrenome'];
$valor = $row['valor-total-controle'];
$data = $row['datamontagem'];
$data = date("d-m-Y",strtotime(str_replace('/','-',$data)));
$status = $row['status'];
echo"
<tr>
<td>$numero</td>
<td>$loja</td>
<td>$cliente $sobrenome</td>
<td>$valor</td>
<td>$data</td>
<td>
<select class='form-control' name='statusm'>
<option value ='$status'>$status</option>
<option value=''>----------</option>
<option value='APROVADO'>APROVADO</option>
<option value='EXECUTANDO'>EXECUTANDO</option>
<option value='CONCLUIDO'>CONCLUIDO</option>
<option value='CANCELADO'>CANCELADO</option>
</select></td>
<td>
<button type='submit' name='mudarStatus' class='btn btn-primary'>
<i class='glyphicon glyphicon-ok'></i> Montar
</button>
<a class='btn btn-default btn-sm' href='fichademoveiseditar.php?codigo=$numero&loja=$loja'><span class='glyphicon glyphicon-pencil'></span></a>
</td>
</tr>";
}
Method:
if(isset($_POST['mudarStatus'])){
$mudar_status=$_POST['statusm[]'];
echo$mudar_status;
echo $controle;