php mysqli事件按日期获取

I have made a code where I get all nubers in the month then I am adding on events from my database. I need the numbers to come from the database in $sqldates I am now only getting array as when I echo the $sqldates. I have 4, 10, 22 and 26 in my database now.

This is what I am getting now look at the picture enter image description here

This is the result I want look at this picture.

enter image description here

How do I get the results from my database as picture 2 shows? Pleas help how to get the numbers from array.

    <table>
    <?php
     //database connent
        include 'con.php'; 
      //get day from event
   $sql = "SELECT day, color FROM events";
   $result = mysqli_query($con, $sql);



$sqldates = array(array('day', 'color_value'), array('date_value', 'color_value'), array('date_value', color_value));
while($row=mysqli_fetch_array($result)){   
array_push($sqldates, $row['day'], $row['color'] );
echo $row['day'];

} 
$counter = 0;
//first day
  $firstday = '1';

  $two = cal_days_in_month(CAL_GREGORIAN, 8, 2018); // 31
//for loop get all day in month  
  for ($number = $firstday; $number <= $two; $number++)


    if (in_array($number , $sqldates)) {
        echo "<td width=50 bgcolor='#{$sqldates[$counter][1]}'>$sqldates[$counter][0]</td>";
        $counter++;
      } else {
        echo"<td width=50 bgcolor='#1e8e8e'>$number</td>";
      }        
    ?>
    </table> 

For your updated question this should be good guide:

<table>
        <?php
         //database connect
            include 'con.php'; 
          //get day from event
          $sql = "SELECT day, color FROM events";
          $result = mysqli_query($con, $sql);

          $sqldates = array();
          $colors = array();
          while($row=mysqli_fetch_array($result)){   
              array_push($sqldates, $row['day']);
              array_push($colors, $row['color']);
          }

          //first day
           $firstday = '1';

          $two = cal_days_in_month(CAL_GREGORIAN, 8, 2018); // 31
          //for loop get all day in month  
           $counter = 0;
          for ($number = $firstday; $number <= $two; $number++)

          if (in_array($number , $sqldates)) {
              echo "<td width=50 bgcolor='$colors[$counter]'>$sqldates[$counter]</td>";
              $counter++;
            } else {
              echo"<td width=50 bgcolor='#1e8e8e'>$number</td>";
          }
      ?>
    </table> 

Note that you need to have defined color for each day, otherwise you will get "Undefined offset" notice.

You are trying to echo an array. Instead you should echo a value from that array with specified index. If I am not wrong, this should work:

//first day
  $firstday = '1';

  $two = cal_days_in_month(CAL_GREGORIAN, 8, 2018); // 31
  //for loop get all day in month  
  $counter = 0;
  for ($number = $firstday; $number <= $two; $number++)

    if (in_array($number , $sqldates)) {
        echo"<td width=50 bgcolor='#f44242'>$sqldates[$counter]</td>";
        $counter++;
      } else {
        echo"<td width=50 bgcolor='#1e8e8e'>$number</td>";
      }