Dear visitors. There is a question. The essence of the situation - you need to display data from the database in a table on the page. If there is an entry in the database, output the contents to a cell; if not, draw an empty cell in the table.
Now the data is drawn only by the query that returns, i.e. the data for which is in the database, the rest is ignored. I tried several output options.
There is another feature - the number of days that shows corresponds to the data from the database, and if you look at the source code of the page, then data about a specific day were added to the desired id, but again there are no empty cells.
Understand the problem: the arr array is multidimensional, associative. I use it with the wrong function and look for the value of $ id in it. Now another difficulty is how to find a dynamically changing $ id in a multidimensional associative array. Found several articles on this topic, but alas ...
$id = strtoupper($info[$i]['id'])."-".$gluing_date; // Π΄Π΅Π»Π°Ρ ΡΠ½ΠΈΠΊΠ°Π»ΡΠ½ΡΠΉ id Π΄Π»Ρ ΠΊΠ°ΠΆΠ΄ΠΎΠ³ΠΎ ΡΠ»Π΅ΠΌΠ΅Π½ΡΠ° <td>, ΡΡΠΎΠ±Ρ Π·Π°ΠΏΠΈΡΡΠ²Π°ΡΡ Π΄Π°Π½Π½ΡΠ΅ Π² Π½ΡΠΆΠ½ΡΡ ΡΡΠ΅ΠΉΠΊΡ $sql = "SELECT id, work_date, cause FROM month_detail WHERE id = '".strtoupper($info[$i]['id'])."' AND work_date = '".$gluing_date."' "; $query = mysqli_query($connect,$sql); //ΠΡΠΏΠΎΠ»Π½Π΅Π½ΠΈΠ΅ Π·Π°ΠΏΡΠΎΡΠ° Π² ΠΠ; // ΡΠΈΠΊΠ» ΠΎΡΡΠΈΡΠΎΠ²ΠΊΠΈ ΡΡΠ΅Π΅ΠΊ ΡΠ°Π±Π»ΠΈΡΡ $t=0; while ($row = mysqli_fetch_assoc($query)) { $arr[$t]['cause'] = $row['cause']; $arr[$t]['concat'] = $row['id']."-".$row['work_date']; if (in_array($id,$arr)){ //ΠΏΡΠΎΠ²Π΅ΡΠΊΠ° $id ΠΊΠ»Π΅ΡΠΊΠΈ <td> Π² ΠΏΠΎΠ»ΡΡΠ°Π΅ΠΌΠΎΠΌ ΠΌΠ°ΡΡΠΈΠ²Π΅, ΡΡΠΎΠ±Ρ Π·Π°ΠΏΠΈΡΠ°ΡΡ ΠΊΠΎΠ½ΠΊΡΠ΅ΡΠ½ΡΡ Π·Π°ΠΏΠΈΡΡ ΠΈΠΌΠ΅Π½Π½ΠΎ Π² ΡΡΠΎΡ id echo "<td class='day'; id='".$id."'> ".$arr[$t]['cause']." </td>"; // Π΅ΡΠ»ΠΈ $id Π΅ΡΡΡ Π² ΠΌΠ°ΡΡΠΈΠ²Π΅ $arr, ΡΠΎ ΠΎΡΡΠΈΡΠΎΠ²Π°ΡΡ <td> Ρ ΡΠΎΠ΄Π΅ΡΠΆΠΈΠΌΡΠΌ ΠΈΠ· ΠΠ } else { echo "<td class='day'; id='".$id."'> </td>"; // Π΅ΡΠ»ΠΈ Π½Π΅Ρ - ΡΠΈΡΠΎΠ²Π°ΡΡ ΠΏΡΡΡΡΡ ΠΊΠ»Π΅ΡΠΊΡ } $t++; } 