我有2个数据库:
在show.php
我有一个使用php运行的日历。我需要显示与日历具有相同日期的用户,如:
用户1,用户2
用户1
用户2
等等。
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>';
}