0
Next, I have a form, inside this Form several Input with vectors, example
<tr>
<td style="vertical-align:middle"> <input type="checkbox" name="Checks[]" value="<?=$id_extrato?>"></td>
<td style="vertical-align:middle"> <?=$select['id']?> </td>
<td style="vertical-align:middle"> <?=$conta['conta']?> </td>
<td style="vertical-align:middle"> <?=$select['nome']?> </td>
<td style="vertical-align:middle"> <?=$select['doc1']?> </td>
<td style="vertical-align:middle"> <?=date("d/m/Y", strtotime($_POST['fecha_solic']));?> </td>
<td style="vertical-align:middle"> <input type="checkbox" name="Pagado[<?=$id_extrato?>]"></td>
<td style="vertical-align:middle"> <?=date("d/m/Y",strtotime($_POST['fecha_pago']));?> </td>
<td style="vertical-align:middle"> <?=$select['total']?> </td>
<td>
<select name="metodo_pagamento[]">
<option value=''>Selecione</option>
<option value='cartao_credito'>Cartão de Crédito</option>
<option value='cartao_credito'>Crédito Iugu</option>
<option value='cartao_debito'>Cartão de Débito</option>
<option value='boleto_avista'>Boleto a vista</option>
<option value='boleto_prazo'>Boleto a Prazo</option>
<option value='dinheiro'>Dinheiro</option>
</select>
</td>
<td><input type="text" name="comentario[]" class="form-control"></td>
</tr>
So when I try to update the fields "Comment" and "Forma_pagto" it brings all the lines that come from the bank, and loses the reference of the marked lines... It turns out I’ve got it like this
Example
Linha 1 : Checked | cartao_credito | Comentario 1
Linha 2 : NON CHECKED | cartão da linha 3 | Comentario da linha 3
In PHP it looks like this
foreach ($_POST["Checks"] as $key => $value)
{
$id_extrato = $value;
if (isset($_POST['metodo_pagamento'][$key]))
{
$metodo_pagamento = $_POST['metodo_pagamento'][$key];
}
else{$metodo_pagamento = "";}
if (isset($_POST['Pagado'][$key]))
{
$pagado = $_POST['Pagado'][$key];
}
else{$pagado = "";}
if ($pagado == true)
{
$status_update = 1;
//echo "<br>pagado: true";
}
else
{
$status_update = 0;
//echo "<br>pagado: false";
}
if (isset($_POST['comentario'][$key]))
{
$comentario = $_POST['comentario'][$key];
}
else{$comentario = "";}
$fecha_solic = $_POST['fecha_solic'];
$data_solic = date("Y-m-d", strtotime($fecha_solic));
$fecha_pago = $_POST['fecha_pago'];
$data_pgto = date("Y-m-d", strtotime($fecha_pago));
The consultation is like this, basically...
$sql_update_extrato = "UPDATE extrato SET status = '$status_update', comentarios = '$comentario', data = '$data_pgto',
data_sol = '$data_solic', forma_pgto = '$metodo_pagamento' where id = '$id_extrato'";
I really don’t understand. Maybe if you explain what you want to get and where you’re stuck. Your problem may be objective, but the context may be important.
– Rene Freak
imagine a grid... I have a table (report) that I wish I could add comment on specific lines and save it in the database, however, I can’t because when I click save it sends only the checks that were marked and ALL inputs of the rest of the table, thus losing the specific reference of what I have to update... That is my problem...
– Diego Ananias
Put more code, and be a little clearer, I didn’t understand much of your problem :)
– LocalHost
As is the table ?
– MagicHat
updated the question with the tabelinha.
– Diego Ananias
And how you’re doing in your php?
– LocalHost
updated again...
– Diego Ananias
Hold on, let me see if I got it now, is he going the fields that are not marked on check? You wanted it to be just the lines that are marked? That’s it?
– LocalHost
Exactly, I need to somehow update only the lines I marked the first checkbox...
– Diego Ananias
You loop in php to generate these form fields?
– LocalHost