mardi 6 décembre 2016

Rendering checkboxes from DB and then update the DB if modifyed

Thanks for coming! So on the DB I have Table1 and Table 2, they have the same columns. What I want to do is that an administrator check the changes requested on Table2 and with a checkbox for each column decide which ones are ok and which others aren't.

So far I have this How it looks

If there are changes between Original and Modified tables the cell turns its color to green and Autochecks itself... So far so good, but.

If I press the Submit button I don't seem to catch the VALUE of the ticked checkbox, so far the maximum I accomplished to catch was a "ARRAY" value, literally, not the content but "ARRAY" just like that, the code of each cell is way to long, Right now I'm focusing on getting the first row right so i can implement that to the other ones, so here is what it looks like: (sorry for the awful mess it is)

<tr>
          <td style="text-align: center">Codigo de Cliente</td>
          <td style="text-align: center"><?php echo $row1['idClientes']; ?></td>
          <td <?php if($row1['idClientes']===$row2['idClientes'])echo "bgcolor='green'  ";?> style="text-align: right"><?php echo $row2['idClientes']; ?><input type="checkbox"  name="checkbox[]" id="checkbox" value:"<?php echo $row2['idClientes']; ?>" <?php if($row1['idClientes']===$row2['idClientes'])echo "checked='checked' onclick='this.checked=!this.checked;' value:'".$row2['idClientes']."'";?> ></td>

 </tr>

And here is the PHP

    <?php if(isset($_POST['submit']))
    {
    $idClientes =$_POST['checkbox'];

  echo "<script>
alert('$idClientes'),
</script> ";}

That echo/alert gives me 'Array' as a result when it should be '14359.

Any advice? Thanks in advance! PD: If the solution excludes Jquery/Javascript that would be awesome, Im not familiar with those languages yet, so only php/mysql/html for now.




Aucun commentaire:

Enregistrer un commentaire