Php内连接和显示结果

时间:2017-12-28 09:34:07

标签: php mysql

我有2个数据库:

  • 持有用户的一个
  • 秒,其中包含用户的年度,月份,日期,日期ID。

show.php

我有一个使用php运行的日历。我需要显示与日历具有相同日期的用户,如:

  1. 用户1,用户2

  2. 用户1

  3. 用户2

  4. 等等。

    private function _showDay($cellNumber){         
        if($this->currentDay==0){             
            $firstDayOfTheWeek = date('N',strtotime($this->currentYear.'-'.$this->currentMonth.'-01'));                     
            if(intval($cellNumber) == intval($firstDayOfTheWeek)){                
                $this->currentDay=1;                 
            }
        }
        if( ($this->currentDay!=0)&&($this->currentDay<=$this->daysInMonth) ){
            $this->currentDate = date('Y-m-d',strtotime($this->currentYear.'-'.$this->currentMonth.'-'.($this->currentDay)));
            $cellContent = $this->currentDay;
            $this->currentDay++;   
        }else{
            $this->currentDate =null;
            $cellContent=null;
        }    
        $conn = new mysqli('localhost', 'root', 'a', 'emp') 
        or die ('Cannot connect to db');
                $sqlday="SELECT emp.name, emp.id, tbl_data.id,tbl_data.year, tbl_data.month, tbl_data.date
                        FROM emp
                        INNER JOIN tbl_data ON emp.id = tbl_data.id 
                        WHERE tbl_data.year = $currentYear
                        AND tbl_data.month = $currentMonth 
                        AND tbl_data.date = $currentDate";
                $resultday = mysqli_query($conn,$sqlday);
    
        return '<p id="li-'.$this->currentDate.'" class="daycounts">'.$cellContent. ''.$resultday.'</p>';
    }
    

0 个答案:

没有答案
相关问题