将数据从sql db导入到不同的下拉菜单中

时间:2013-05-23 09:22:18

标签: php mysql

我有一张employee的表格,在该表格中,我one column named birthdate存储了date in 2012/4/5 format

在php页面中,我有3 drop down menu called year, month and date

任何人都可以帮助我...如何将日期提取到3个不同的下拉菜单?日Thnx

2 个答案:

答案 0 :(得分:1)

in your PHP code use split method like this:

list($y,$m,$d) = split("/",$dob); // 2012/4/5

then use $y, $m and $d value as you want.

答案 1 :(得分:1)

您可以使用爆炸功能:

 <body>
 <?php
 $date = '2012/4/5';
 $date = explode('/',$date);
 ?>
 <select name="year">
     <option value="year"><?php echo $date[0]; ?></option>
 </select>
 <select name="month">
     <option value="month"><?php echo $date[1]; ?></option>
 </select>
 <select name="day">
     <option value="day"><?php echo $date[2]; ?></option>
 </select>
 </body>