Dear visitors. There is a question.
The essence of the situation – it is necessary to display data from the database to the table on the page.
If the entry in the database is, output the contents into the cell, if not, draw an empty cell in the table.
Now the data is drawn only by those that return the query, i.e. The data on which is in the database, the rest is ignored. I tried several output options.
There is another feature – the number of days that shows data from the database, and if you look at the source code of the page, then the data on the specific day was added to the necessary ID, but again there are no empty cells.
understood what the problem is: Arr array – multidimensional, associative. It is not the function to go through it and seeking the value of the $ ID in it. Now another difficulty, how to find a dynamically changing $ ID in a multidimensional associative array. Found a few articles on this topic, but alas …
$ id = strtoupper ($ info [$ i] ['id']). "-". $ gluing_date; // Making a unique ID for each element & lt; TD & GT; to record the data in the desired cell
$ 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); // execution of the query in the database;
// Cycle Recover Table Cells
$ 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)) {// Checking $ ID Cage & LT; TD & GT; In the resulting array to record a specific entry in this id
Echo "& lt; td class = 'day'; id = '". $ ID. "' & GT;" $ ARR [$ T] ['Cause']. "& lt; / td & gt;"; // If $ ID is in $ ARR array, then draw & lt; TD & GT; with content from database
} else {
Echo "& lt; TD Class = 'Day'; id = '". $ ID. "' & gt; & amp; nbsp; & lt; / td & gt;"; // if not - draw an empty cage
}
$ T ++;
}
Answer 1
Have you watched the source page that is displayed?
If there is
& lt; td & gt; & lt; / td & gt;
That empty cells are displayed, they are simply not visible in the browser.
Try to substitute instead of an inseparable space any letter and see if it is displayed.
Answer 2
Set the cells and height cells with CSS, you can set the radius. And will work
& lt; td style = "border: 1px solid red; width: 50px; height: 50px;" & gt; & amp; nbsp; & lt; / td & gt;
Iron draws a cell
Answer 3
Selection, assignment and logic is logically correct.
The function that searches for the value in the array is incorrectly selected.
Constor
if (in_array ($ ID, $ ARR)) {// Checking $ Cell ID & LT; TD & GT; In the resulting array to record a specific entry in this id
Echo "& lt; td class = 'day'; id = '". $ ID. "' & GT;" $ ARR [$ T] ['Cause']. "& lt; / td & gt;"; // If $ ID is in $ ARR array, then draw & lt; TD & GT; with content from database
} else {
Echo "& lt; TD Class = 'Day'; id = '". $ ID. "' & gt; & amp; nbsp; & lt; / td & gt;"; // if not - draw an empty cage
}
Use the In_Array function is unacceptable, as the search is carried out in a multidimensional associative array. Therefore, the condition described is not performed.