如何将日期放入数据库

时间:2016-01-07 13:58:09

标签: php html sql

我必须从数据库中获取日期并将其放入type =“date”的输入中但没有任何作用...... 我的代码:

$id_repres = $_GET['id_repres'];
include_once('../config_path.php');
$bdd->query("SET NAMES 'utf8'");
$req = "SELECT * FROM representation WHERE id_repres='".$_GET['id_repres']."'";
$result = $bdd->query($req);
$affiche_repres = $result->fetchAll();
foreach($affiche_repres as $key => $value){
    $nom = $value['nom_repres'];
    $desc = $value['desc_repres'];
    $date = $value['date_repres'];
    $prix = $value['prix_place_repres'];
    $img = $value['img_repres'];
    $img_presse = $value['img_presse_repres'];
    $lien1 = $value['lien1_repres'];
    $lien2 = $value['lien2_repres'];
}
?>
<form action="modif_repres_valid.php" method="post" id="form_update">
    <label for="nom_repres">Intitulé </label><input type="text" id="nom_repres" name="nom_repres" required value="<?php echo $nom ?>"><br><br>
    <label for="desc_repres">Description </label><input type="text" id="desc_repres" name="desc_repres" required value="<?php echo $desc ?>"><br><br>
    <label for="date_repres">Date et Heure </label><input type="datetime-local" id="date_repres" name="date_repres" required min="1950-01-01T00:00:00" max="2026-12-31T23:59:59" value="<?php echo dateLongue($date) ?>"><br><br>
    <label for="prix_place_repres">Prix </label><input type="text" id="prix_place_repres" name="prix_place_repres" pattern="\d{1,2}" required value="<?php echo $prix ?>"><br><br>
    <label for="img_repres">Image </label><input type="text" id="img_repres" name="img_repres" required value="<?php echo $img ?>"><br><br>
    <label for="img_presse_repres">Presse </label><input type="text" id="img_presse_repres" name="img_presse_repres" required value="<?php echo $img_presse ?>"><br><br>
    <label for="lien1_repres">Lien 1 </label><input type="text" id="lien1_repres" name="lien1_repres" required value="<?php echo $lien1 ?>"><br><br>
    <label for="lien2_repres">Lien 2 </label><input type="text" id="lien2_repres" name="lien2_repres" required value="<?php echo $lien2 ?>"><br><br>
    <input type="hidden" id="id_repres" name="id_repres" value="<?php echo $_GET['id_repres']; ?>">

    <button type="submit" form="form_update" value="Submit">Valider</button>
</form>

谢谢你的回答! :)

1 个答案:

答案 0 :(得分:1)

Internet Explorer和Firefox不支持带有<input>

type="datetime-local"个元素。

我认为您应该将输入字段的类型更改为文字日期日期时间