Update $modified on edit

Update $modified on edit

frabapreclfrabaprecl Posts: 3Questions: 1Answers: 0

Using editor, I have a database where I want to know who last updated any cell.
$modified is what I want updated on any successful edit with $username.

Answers

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395

    You don't provide much information.
    Where does $username come from?
    What data type is the $modified field?
    Are you using Editor's PHP libraries?

  • frabapreclfrabaprecl Posts: 3Questions: 1Answers: 0

    So all the information comes from the mysql database.
    $username is being set as a variable per user login.
    $modified will be set to $username so we know who last modified the table.
    I am using editors PHP libraries.
    working site http://esig.hkgdf.com/edit.php

  • allanallan Posts: 63,075Questions: 1Answers: 10,384 Site admin

    Can you show us the PHP code please?

    Allan

  • frabapreclfrabaprecl Posts: 3Questions: 1Answers: 0
    <?php
     session_start();
    // if( !isset($_SESSION['myusername']) or !isset($_SESSION['access'])){
    // header("location:index.php");
    // exit();
    // }
    
    <?php
    >
    <?php 
        require 'db_connection.php';
        
    >
    <!DOCTYPE html>
    
    
    ?>
    
    
        <meta charset="utf-8"/>
        <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
        <meta name="viewport" content="width=device-width, initial-scale=1"/>
        <meta name="description" content=""/>
        <meta name="author" content=""/>
    
        <title>HKG Invoice</title>
    
        <!-- Bootstrap Core CSS -->
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css"/>
        <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.16/css/dataTables.bootstrap.min.css">
        <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/responsive/2.2.1/css/responsive.bootstrap.min.css">
        <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css">
        <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/buttons/1.5.1/css/buttons.dataTables.min.css">
        <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/select/1.2.5/css/select.dataTables.min.css">
        <link rel="stylesheet" type="text/css" href="http://esig.hkgdf.com/css/editor.dataTables.min.css">
        <link rel="stylesheet" type="text/css" href="http://esig.hkgdf.com/resources/syntax/shCore.css">
    
        <style type="text/css" class="init">
        
        </style>
    
        <script src="https://code.jquery.com/jquery-2.1.3.min.js"></script>
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>
        <script src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script>
        <script src="https://cdn.datatables.net/1.10.16/js/dataTables.bootstrap.min.js"></script>
        <script src="https://cdn.datatables.net/responsive/2.2.1/js/dataTables.responsive.min.js"></script>
        <script src="https://cdn.datatables.net/responsive/2.2.1/js/responsive.bootstrap.min.js"></script>
        <script type="text/javascript" language="javascript" src="https://cdn.datatables.net/buttons/1.5.1/js/dataTables.buttons.min.js"></script>
        <script type="text/javascript" language="javascript" src="https://cdn.datatables.net/select/1.2.5/js/dataTables.select.min.js"></script>
        <script type="text/javascript" language="javascript" src="http://esig.hkgdf.com/js/dataTables.editor.min.js"></script>
        <script type="text/javascript" language="javascript" src="http://esig.hkgdf.com/resources/syntax/shCore.js"></script>
        <script type="text/javascript" language="javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
        <script type="text/javascript" language="javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/pdfmake.min.js"></script>
        <script type="text/javascript" language="javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/vfs_fonts.js"></script>
        <script type="text/javascript" language="javascript" src="https://cdn.datatables.net/buttons/1.5.1/js/buttons.html5.min.js"></script>
        <script type="text/javascript" language="javascript" src="https://cdn.datatables.net/buttons/1.5.1/js/buttons.print.min.js"></script>
        <script type="text/javascript" language="javascript" src="http://esig.hkgdf.com/resources/demo.js"></script> 
        <script type="text/javascript" language="javascript" src="http://esig.hkgdf.com/resources/editor-demo.js"></script> 
        <!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
        <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
        <![endif]-->
    <script type="text/javascript" language="javascript" class="init">
        
    
    
    var editor; // use a global for the submit and return data rendering in the examples
    
    $(document).ready(function() {
        editor = new $.fn.dataTable.Editor( {
            ajax: "/php/staff.php",
            table: "#example",
            fields: [ {
                    label: "ID:",
                    name: "id"
                }, {
                    label: "Invoice Number:",
                    name: "invoice_no"
                }, {
                    label: "Customer:",
                    name: "customer"
                }, {
                    label: "Amount:",
                    name: "amount"
                }, {
                    label: "Due Amount:",
                    name: "due_amount"
            }, {
                    label: "Date:",
                    name: "date",
                    type: "datetime"
                }, {
                    label: "Location:",
                    name: "location",
                    type:  "select",
                    options: [
                    { label: "006 Roma", value: "006 Roma" },
                    { label: "005 Hidalgo", value: "005 Hidalgo" },
                    { label: "011 Laredo 3", value: "011 Laredo 3" },
                    { label: "012 El Paso", value: "012 El Paso" },
                    { label: "018 Otay", value: "018 Otay" },
                    { label: "019 San Ysidro", value: "019 San Ysidro" },
                    { label: "023 Laredo 4", value: "023 Laredo 4" }
                            ]
                }, {
                    label: "Courier:",
                    name: "delivery"
                }, {
                    label: "Account:",
                    name: "account"
                }, {
                    label: "Last Modified:",
                    name: "modified"
                }, {
                    label: "Created:",
                    name: "created"
                }
            ]
        } );
    
        // Activate an inline edit on click of a table cell
        $('#example').on( 'click', 'tbody td:not(:first-child)', function (e) {
            editor.inline( this );
        } );
    
        $('#example').DataTable( {
            dom: "Bfrtip",
            ajax: "/php/staff.php",
            order: [[ 1, 'desc' ]],
            columns: [
                {
                    data: null,
                    defaultContent: '',
                    className: 'select-checkbox',
                    orderable: false
                },
                { data: "id" },
                { data: "invoice_no" },
                { data: "customer" },
                { data: "amount" },
                { data: "due_amount" },
                { data: "date" },
                { data: "location" },
                { data: "delivery" },
                { data: "account" },
                { data: "modified" },
                { data: "created" }
            ],
            select: {
                style:    'os',
                selector: 'td:first-child'
            },
            buttons: [
                        { extend: "edit",   editor: editor },
                                    {
                    extend: 'collection',
                    text: 'Export',
                    buttons: [
                        'copy',
                        'excel',
                        'csv',
                        'pdf',
                        'print'
                    ]
                }
                        ]
        } );
    } );
        </script>
            <style>
            body {
                padding-top: 70px;
            }
        </style>
    </head>
        
    <body>
    
    <!-- Navigation -->
    <nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
        <div class="container">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target=".navbar-collapse">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <a class="navbar-brand" href="main.php">HKG Invoice</a>
            </div>
            <div class="collapse navbar-collapse">
                <ul class="nav navbar-nav">
                    <li><a href="main.php">Create Invoice</a></li>
                          <?php
    $link1 = "<li class='active'><a href='view_invoices.php'>View Invoices</a></li>";
    if ($_SESSION['access'] === '1' ) {
        echo $link1;    
    }else{  
        
    }
    
    <?php
    >
                    
                    
                    Logout
                
            
            
        
        
    
    ?>
    
    
    <!-- Page Content -->
    <div class="container">
        <div class="row">
            <div class="col-md-12">
                <div class="col-sm-6 col-md-12">
                    <h2>Edit Invoices</h2>
                                          <a class="btn btn-primary btn-xs" href="view_invoices.php">Show Regular</a>
    
                                <table id="example" class="table table-striped table-bordered" cellspacing="0" width="100%">
                    <thead>
                        <tr>
                        <th></th>
    
                <th>ID</th>
    
                    <th>Invoice No</th>
                    <th>Customer</th>
    
                <th>Amount</th>
    
                <th>Due Amount</th>
    
                <th>Date</th>
    
                <th>Location</th>
    
                            <th>Courier</th>
    
                            <th>Account</th>
                            <th>Last Modifed</th>
    
                            <th>Created</th>
                        </tr>
                    </thead>
                </table>
                </div>
            </div>
        </div>
    </div>
    <!-- /.container -->
    </body>
    </html>
    
This discussion has been closed.