Paint table with data stored in the database

0

When you paint the table and fill it, it shows the data of the last line that was saved, but in the database if the correct values of the previous values are saved but in the load it only shows the last one.

$sql = mysqli_query($con, "select * from document where project_id in (".$project_id.
  ")");

if ($project_id <= 1) {

  while ($row = mysqli_fetch_array($sql)) {
    $array = $row['project_id'];
    $array1 = explode(',', $array);

    $code = mysqli_query($con, "SELECT * FROM project WHERE id = $array1");

    if ($code = '') {
      $project = '';
      foreach($code["name"] as $row) {
        $project. = $row.
        ', ';
      }
      $project = substr($project, 0, -2);
    }
  }
} else {

  while ($row = mysqli_fetch_array($sql)) {
    $array = $row['project_id'];
    $array1 = explode(',', $array);
    $project = '';

    foreach($array1 as $id) {
      $code = mysqli_query($con, "SELECT * FROM project WHERE id = $id");

      while ($row1 = mysqli_fetch_array($code)) {
        $project. = $row1['name'].
        ', ';
      }
    }
    $project = substr($project, 0, -2);
  }
}

The first record is saved shows well the department field

Save the second record shows well the department field

When you save the third one, it is when you give the error in the department load and change the first one and leave it the same as the third one that was saved.

But in the Database if the values of the department are well stored

    
asked by Julián Cordoba 18.06.2018 в 18:10
source

0 answers