0
Hello, I’m making a control panel of a scoreboard, where I have a screen with all the games of the round and as the games are already previously registered on the bench, I need to update the games as the rounds occur. I managed to pass the game ID, but the other inputs with the results did not.
PHP
<?php
while($ln = mysqli_fetch_assoc($qr)){
?>
<form id="frmPlacar" method="post">
<TABLE align="center">
<TR>
<TH rowspan="2">
<INPUT type="checkbox" name="ids[]" id="ids" value="<?php echo $ln['id_placar'];?>">
</TH>
<TH>
<INPUT type="text" name="time1" value="<?php echo $ln['nm_time1'];?>" placeholder="Time visitante" disabled>
</TH>
<TD>
<INPUT type="text" name="placar1_1" value="<?php echo $ln['nr_placar1_1'];?>" placeholder="1º Q" maxlength="2">
</TD>
<TD>
<INPUT type="text" name="placar1_2" value="<?php echo $ln['nr_placar1_2'];?>" placeholder="2º Q" maxlength="2">
</TD>
<TD>
<INPUT type="text" name="placar1_3" value="<?php echo $ln['nr_placar1_3'];?>" placeholder="3º Q" maxlength="2">
</TD>
<TD>
<INPUT type="text" name="placar1_4" value="<?php echo $ln['nr_placar1_4'];?>" placeholder="4º Q" maxlength="2">
</TD>
<TD>
<INPUT type="text" name="placar1_o" value="<?php echo $ln['nr_placar1_o'];?>" placeholder="OT" maxlength="2">
</TD>
<TD>
<INPUT type="text" name="placar1_f[]" value="<?php echo $ln['nr_placar1_f'];?>" placeholder="FINAL" maxlength="2">
</TD>
<TD>
<INPUT type="text" name="campanha1" value="<?php echo $ln['nm_campanha1'];?>" placeholder="CAMPANHA" maxlength="7">
</TD>
</TR>
<TR>
<TH>
<INPUT type="text" name="time2" value="<?php echo $ln['nm_time2'];?>" placeholder="Time mandante" disabled>
</TH>
<TD>
<INPUT type="text" name="placar2_1" value="<?php echo $ln['nr_placar2_1'];?>" placeholder="1º Q" maxlength="2">
</TD>
<TD>
<INPUT type="text" name="placar2_2" value="<?php echo $ln['nr_placar2_2'];?>" placeholder="2º Q" maxlength="2">
</TD>
<TD>
<INPUT type="text" name="placar2_3" value="<?php echo $ln['nr_placar2_3'];?>" placeholder="3º Q" maxlength="2">
</TD>
<TD>
<INPUT type="text" name="placar2_4" value="<?php echo $ln['nr_placar2_4'];?>" placeholder="4º Q" maxlength="2">
</TD>
<TD>
<INPUT type="text" name="placar2_o" value="<?php echo $ln['nr_placar2_o'];?>" placeholder="OT" maxlength="2">
</TD>
<TD>
<INPUT type="text" name="placar2_f[]" value="<?php echo $ln['nr_placar2_f'];?>" placeholder="FINAL" maxlength="2">
</TD>
<TD>
<INPUT type="text" name="campanha2" value="<?php echo $ln['nm_campanha2'];?>" placeholder="CAMPANHA" maxlength="7">
</TD>
</TR>
<TR>
<TD colspan="8" class="bt" align="right">
<input type="hidden" value="<?php echo $ln['id_placar'];?>" name="jogos[]" id="jogo">
<button class="btn btn-small btn-success" id="botao"><i class="icon-thumbs-up icon-white"></i>Alterar</button>
</TD>
</TR>
<TR>
<TD colspan="8" align="left">
<div id="erro">Erro:</div>
<div id="sucesso">Sucesso:</div>
</TD>
</TR>
</TABLE>
</form>
<?php
}
?>
AJAX
$(document).ready(function(){
$(document).on('click', '#botao', function () {
var Jogo = new Array();
$("input[name='ids[]']:checked").each(function(){
Jogo.push(parseInt($(this).val()));
alert(Jogo);
});
$.ajax({
type: "POST",
url: "teste.php",
data: "jogo="+Jogo,
success: function(html){
if(html=='true')
{
$("#erro").html("");
$("#sucesso").html("Placar atualizado com sucesso!");
}
else
{
$("#erro").html(html);
$("#sucesso").html("");
}
},
beforeSend:function()
{
$("#erro").html("");
$("#sucesso").html("");
}
});
return false;
})
})
Ricardo the answer below solved your problem?
– Sergio