如何从datepicker中将日期名称设置为mysql数据库中的列名..?

时间:2017-04-03 14:14:05

标签: php mysql datepicker

例如如果我从datepicker中选择日期,如果那天是星期三,我想从" wed"中获取所有数据。仅具有特定值的列.....

我需要php代码和mysql qyery吗?

-- Table structure for table `list`
--

CREATE TABLE `list` (
  `id` int(11) NOT NULL auto_increment,
  `Mon` char(1) default NULL,
  `Tue` char(1) default NULL,
  `Wed` char(1) default NULL,
  `Thur` char(1) default NULL,
  `Fri` char(1) default NULL,
  `Sat` char(1) default NULL,
  `Sun` char(1) default NULL,
  PRIMARY KEY  (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=20 ;

1 个答案:

答案 0 :(得分:0)

对于php代码

$weekday[0]="Sun";
$weekday[1]="Mon";
$weekday[2]="Tues";
$weekday[3]="Wed";
$weekday[4]="Thur";
$weekday[5]="Fri";
$weekday[6]="Sat";


$date = '2011/10/14'; 
$dayName = date('D', strtotime($date));
$dayNumber = date('N', strtotime($date));
echo $dayName; //date name 
$prefix = $weekday[$dayNumber]; //custom date name
$query = "select * from table_name where $prefix = 'Y'";