2016-05-19 13 views
1

user_reservation.phpInsert-Status in der Datenbank

<thead> 
    <tr> 
    <th scope="col">Number of Guest</th> 
    <th scope="col">Type of Service</th> 
    <th scope="col">Date</th> 
    <th scope="col">Time</th> 
    <th scope="col">Status</th> 
    <th scope="col">Edit</th> 

     </tr> 
    </thead> 
    <tbody> 
    <?php 


    include 'include/db_config.php'; 

    $result = $dbs->prepare("SELECT * FROM service_info WHERE id = :id"); 
    $result->bindParam(':id', $_SESSION['id']); 
    $result->execute(); 
    for($i=0; $row = $result->fetch(); $i++){ 

    ?> 
    <tr class="record"> 
    <td><?php echo $row['no_guest']; ?></td> 
    <td><?php echo $row['type_service']; ?></td> 
    <td><?php echo $row['datepicker']; ?></td> 
    <td><?php echo $row['t_time']; ?></td> 
    <td><?php echo $service['status']; ?></td> 
    <td><a href="editform.php?id=<?php echo $row['id']; ?>"> edit </a></td> 

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

    <b>STATUS</b><br> 

    <?php 


    include 'include/db_config.php'; 

    $result = $dbs->prepare("SELECT * FROM service_info WHERE id = :id"); 
    $result->bindParam(':id', $_SESSION['id']); 
    $result->execute(); 
    for($i=0; $row = $result->fetch(); $i++){ 
    ?> 

    <!--<td><?php //echo $row['datepicker']; ?></td>--> 

    <?php 
    $today = date("Y-m-d H:i:s"); 
    $startdate = $row['datepicker']; 
    $offset = strtotime("+2 day"); 
    $enddate = date($startdate, $offset);  
    $today_date = new DateTime($today); 
    $expiry_date = new DateTime($enddate); 


    $status = ($expiry_date < $today_date) ? 'Expired' : 'Active' ; 
    $result = $dbs->prepare("UPDATE Customers SET status = :status WHERE id =  :id"); 
    $result->bindParam(':id', $_SESSION['id']); 
    $result->bindParam(':status', $status); 
    $result->execute(); 
    ?> 
    <?php 
    } 
    ?> 

Das ist mein ganzer Code auf user_reservation. Alles, was ich auf meiner Admin-Reservierung wollte, war, was in meiner Status-Datenbank zu holen. aber wie man sehen kann ich kann immer noch die Statusdaten in der Datenbank

Antwort

0

Hinzufügen einer Spalte ‚Status‘ in der Tabelle ‚service_info‘ einfügen mit phpMyAdmin zum Beispiel dann in Ihrer Zeit Überprüfung:

include 'include/db_config.php'; 

$result = $dbs->prepare("SELECT * FROM service_info WHERE id = :id"); 
$result->bindParam(':id', $_SESSION['id']); 
$result->execute(); 
for($i=0; $row = $result->fetch(); $i++){ 
?> 

<?php 
$today = date("Y-m-d H:i:s"); 
$startdate = $row['datepicker']; 
$offset = strtotime("+2 day"); 
$enddate = date($startdate, $offset);  
$today_date = new DateTime($today); 
$expiry_date = new DateTime($enddate); 

$status = ($expiry_date < $today_date) ? 'Expired' : 'Active' ; 
$result = $dbs->prepare("UPDATE Customers SET status = :status WHERE id = :id"); 
$result->execute(array(':status'=>$status, ':id'=>$_SESSION['id'])); 

dann in Ihrer Tabelle, geben Sie einfach die Statusspalte:

<tr class="record"> 
<td><?php echo $customers[$key]['firstname'];?></td> 
<td><?php echo $service['no_guest']; ?></td> 
<td><?php echo $service['type_service']; ?></td> 
<td><?php echo $service['datepicker']; ?></td> 
<td><?php echo $service['t_time']; ?></td> 
<td><?php echo $service['status']; ?></td> 
+0

Lassen Sie mich dieses Sir zuerst versuchen. – Ginxx0009

+0

Ich bearbeitete einige;), wenn Sie einen Fehler erhalten, fügen Sie es hier pls :) –

+0

übrigens Sir sie sind in verschiedenen form.php – Ginxx0009