2016-10-22 4 views
1

Ich möchte das Datum in MySQL im niederländischen Format eingeben. jetzt gibt er mir das Standardformat. Muss ich es in den Ausgabelisten oder in den Einfügedateien ändern?Konvertieren Sie das Datum in das niederländische Format

Das ist mein Insert-Code ist:

<?php 
session_start(); 


include '../dbh.php'; 

$costname = $_POST['costname']; 
$category = $_POST['category']; 
$subcategory = $_POST['subcategory']; 
$price = $_POST['price']; 
$info = $_POST['info']; 
$costdate = $_POST['costdate']->format("d-m-Y H:i:s"); 
$iduser = $_SESSION['id']; 

if(empty($costname)) { 
    header("Location: ../dashboard.php?error=emptycostname"); 
    exit(); 
} 

if(empty($category)) { 
    header("Location: ../dashboard.php?error=emptycatergory"); 
    exit(); 
} 

if(empty($subcategory)) { 
    header("Location: ../dashboard.php?error=emptysubcatergory"); 
    exit(); 
} 

if(empty($price)) { 
    header("Location: ../dashboard.php?error=emptyprice"); 
    exit(); 
} 

if(empty($info)) { 
    header("Location: ../dashboard.php?error=emptyinfo"); 
    exit(); 
} 

else { 
    $sql = "INSERT INTO costs (costname, category, subcategory, price, info, userid, costdate) 
    VALUES ('$costname', '$category', '$subcategory', '$price', '$info', '$iduser', '$costdate')"; 

    $result = mysqli_query($conn, $sql); 

    header("Location: ../dashboard.php"); 

} 

ich es auf einer Liste Jetzt müssen angezeigt werden, ich habe diesen Code machte es aus der db zu bekommen:

<?php 
include('includes/sessionstart.php'); 
include 'dbh.php'; 
if (isset($_SESSION['id'])) { ?> 


    <?php include 'includes/header.php'; 




    // costslist define mysql 
    $sql_costs = "SELECT * FROM costs WHERE userid='".$_SESSION['id']."'"; 
    $result_costs = mysqli_query($conn, $sql_costs); 




    $costname = $row_costs['costname']; 





    <div class="content"> 
     <div class="container-fluid"> 
      <div class="row"> 
       <div class="col-md-12"> 
        <div class="card"> 
         <div class="header"> 
          <h4 class="title">Wonen</h4> 
          <p class="category">Kosten gespendeerd aan uw woning.</p> 
         </div> 
         <div class="content table-responsive table-full-width"> 
          <table class="table table-hover table-striped"> 
           <thead> 
                    <th>Subcategorie</th> 
                    <th>Kostnaam</th> 
                    <th>Kostprijs</th> 
                    <th>Extra info</th> 
                    <th>Datum toegevoegd</th> 

           </thead> 
           <tbody> 

                      <?php 
                      while($row = $result_costs->fetch_assoc()) { ?> 
                       <tr> 
                        <td><?php echo $row['subcategory']; ?></td> 
                        <td><?php echo $row['costname']; ?></td> 
                        <td><?php echo $row['price']; ?></td> 
                        <td><?php echo $row['info']; ?></td> 
                        <td><?php echo $row['costdate']; ?></td> 

                        </tr> 
                      <?php } ?> 
           </tbody> 
          </table> 

         </div> 
        </div> 
       </div> 
+0

Bitte beachten Sie, dass Ihr Code auf SQL-Injection-Angriffe anfällig ist, setzen Sie Ihre Server in Gefahr. Lesen Sie hier mehr darüber, wie Sie es sicher machen: https://stackoverflow.com/questions/60174/how-can-i-prevent-sql-injection-in-php –

Antwort

Verwandte Themen