Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
157 views
in Technique[技术] by (71.8m points)

php - how to set date day name from datepicker as column name in mysql database..?

for e.g. if i pick date from datepicker and if that day is wednesday i want to get all data from "wed" column having particualr value only.....

i need php code and mysql qyery for this??

-- 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 ;
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

For php code

$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'";

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...