Php tarih ayırmak için nasıl

2 Cevap php

I want to be able to separate the birthday from the mysql data into day, year and month. Using the 3 textbox in html. How do I separate it? I'm trying to think of what can I do with the code below to show the result that I want:

İşte php kodu ile html formu var:

$idnum = mysql_real_escape_string($_POST['idnum']);

mysql_select_db("school", $con);
  $result = mysql_query("SELECT * FROM student WHERE IDNO='$idnum'");

  $month = mysql_real_escape_string($_POST['mm']);
?>       
<?php while ( $row = mysql_fetch_array($result) ) { ?>
    <tr>
    <td width="30" height="35"><font size="2">Month:</td>
    <td width="30"><input name="mo" type="text" id="mo"  onkeypress="return handleEnter(this, event)" value="<?php  echo $month = explode("-",$row['BIRTHDAY']);?>">

Gördüğünüz gibi sütun MySQL veritabanı DOĞUM denilmektedir. Bu format ile:

YYYY-MM-DD

How do I do it. So that the data from the single column will be divided into three parts? Please help thanks,

2 Cevap

Sen istenilen sonucu elde etmek için listeyi kullanın ve patlayabilir

 list($year,$month,$day)=explode("-", $row['birthday']);

dolayısıyla $ yıl yıl içeren, $ ay ay içerir ve $ günde Günü içeriyorsa, metin kutuları bu gibi kullanabilirsiniz

<input name="mo" type="text" id="mo" value="<?php echo $month;?>">
<input name="dt" type="text" id="dt" value="<?php echo $day;?>">
<input name="yr" type="text" id="yr" value="<?php echo $year;?>">

Bunu ayrı compoents içine tarih bölmek için php patlayabilir işlevini kullanabilirsiniz:

$birthday ="1981-06-22";
list($year, $month, $day) = explode("-", $birthday);
echo "\nDay $day Month $month Year $year";