jeudi 27 juin 2019

Checkbox does not for each row

I have a list of 1624 items you can choose with a checkbox, but in the form, it can detect 'on' only for the 622 first items. If rows are checked below it does not return 'on'.

I display a list of pieces from a database, you can choose pieces thanks to a checkbox and then the database is uptaded. It works for all the items at the top of the list but starting from a row, if the box is checked, it is not detected in the php form. Whatever the order of the piece is, it works only for the 622 first items. I do not understand where is the issue since, I think, it does not come from the variables. I wonder if it is a problem of time execution, or, if by default, it stops looking from a certain row.

I have all ready verified if the algorithm check each line and it does and if all variables are good.

  $cpt = 1;
  $id_asm = (isset($_GET['id'])) ? $_GET['id'] : "";
  $SQLQuery2="(select * FROM pieces";
  $SQLResult2 = mysqli_query($MySqliConn, $SQLQuery2);
  $_html_tbStock .= '<tr>';
  // [...other information for the list...]

  while ($row2 = mysqli_fetch_array($SQLResult2, MYSQLI_ASSOC)) {            
      $idpiece = $row2['ID_PIECE'];
      $SQLQuery4 = "SELECT * from parametrage_envoi_stock where ID_ASM = '". $id_asm . "' AND ID_PIECE ='". $idpiece ."'";
      $SQLResult4 = mysqli_query($MySqliConn, $SQLQuery4);
      $row4 = mysqli_fetch_array($SQLResult4, MYSQLI_ASSOC);
      $pointee = ($row4['COCHE'] != 0) ? 'checked="checked"' : ''
      //if the piece was checked before, it is checked by default in the display, else it is not

      $_html_tbStock .= '<td><input id="parametrage_' . $cpt . '" name="parametrage_' . $cpt . '" type="checkbox" ' . $pointee . '/></td>';
      $_html_tbStock .= '</tr>';
    $cpt++;

    }

In the form we got this :

 $totalpiece = 1624
 $cpt = 1;
 while ($cpt <= $totalpiece) {
   if (isset($_POST['parametrage_' . $cpt])) {
        $ref = $_POST['ref_' . $cpt];
        $rev = $_POST['rev_' . $cpt];
        $nom = $_POST['nom_' . $cpt];
        var_dump($ref);
        var_dump($rev);
        var_dump($nom);

        $SQLQuery2 = "SELECT * FROM pieces WHERE REF_PIECE LIKE '%". $ref ."%' AND REV_PIECE LIKE '%". $rev ."%' AND NOM_PIECE LIKE '%". $nom ."%'";
        $SQLResult2 = mysqli_query($MySqliConn, $SQLQuery2) or die('Erreur2<br />' . mysqli_error($MySqliConn));
        $cnt = 1;
        while ($row2 = mysqli_fetch_array($SQLResult2, MYSQLI_ASSOC)) {
            $id_piece = $row2['ID_PIECE'];
            $SQLQuery2 = "INSERT INTO parametrage_envoi_stock (ID_ASM, ID_PIECE,COCHE) VALUES ('$idasm','$id_piece','1')";
            mysqli_query($MySqliConn, $SQLQuery2) or die('Erreur 1<br />' . mysqli_error($MySqliConn));
            var_dump($SQLQuery2);
            $cnt++;
        }
     }

    }

The list with all items and checkboxes is displayed. We can click on all the chekboxes we want.




Aucun commentaire:

Enregistrer un commentaire