need help with temperature table (editor datatables)

need help with temperature table (editor datatables)

MaizakungMaizakung Posts: 3Questions: 1Answers: 0

Hello everyone
first i have to tell i'm not good with English.

so here my problem

i need to make a table to collect an body temperature value everyday and 3 time 1.morning 2.afternoon 3.evening

i don't want timestamp because lag of user input.

so anyone have guideline or suggestion?

please help :neutral:

Answers

  • MaizakungMaizakung Posts: 3Questions: 1Answers: 0
    edited May 2019

    i have another problem now

    i want to edit value and loop on meas_id and id in measurements

        <?php
    
          include 'includes/header.php';
          include 'includes/navbar.php';
    
        ?>
    
        <script>
    
        var editor; // use a global for the submit and return data rendering in the examples
    
        $(document).ready(function() {
            editor = new $.fn.dataTable.Editor( {
                ajax: "includes/meas.php",
                table: "#example",
                fields: [
                  {
                    label: "First name:",
                    name: "new_recruited.first_name"
                  },
                  {
                    label: "Last name:",
                    name: "new_recruited.last_name"
                  },
                  {
                    label: "Temp Day",
                    name: "mean.temp_day"
                  },
                  {
                    label: "Temp Noon",
                    name: "mean.temp_noon"
                  }
                ]
            } );
    
            $('#example').DataTable( {
                dom: "Bfrtip",
                ajax: "includes/meas.php",
                columns: [
                    { data: "new_recruited.first_name" },
                    { data: "new_recruited.last_name" },
                    { data: "mean.temp_day" },
                    { data: "mean.temp_noon" },
                ],
                select: true,
                buttons: [
                    { extend: "create", editor: editor },
                    { extend: "edit",   editor: editor },
                    { extend: "remove", editor: editor }
                ]
            } );
        } );
    
        </script>
    
        <div class="container-fluid">
          <div class="row">
            <div class="col">
              <table id="example" class="display" style="width:100%">
                      <thead>
                          <tr>
                              <th>Name</th>
                              <th>Last Name</th>
                              <th>Meas</th>
                              <th>Noon</th>
                          </tr>
                      </thead>
                      <tfoot>
                          <tr>
                              <th>Name</th>
                              <th>Last Name</th>
                              <th>Meas</th>
                              <th>Noon</th>
                          </tr>
                      </tfoot>
                  </table>
            </div>
          </div>
        </div>
    
        <?php
    
          include 'includes/footer.php';
    
        ?>
    

    Here php file call meas.php

        <?php
          include( "../../editor/lib/DataTables.php" );
          use
              DataTables\Editor,
              DataTables\Editor\Field,
              DataTables\Editor\Format,
              DataTables\Editor\Mjoin,
              DataTables\Editor\Options,
              DataTables\Editor\Upload,
              DataTables\Editor\Validate,
              DataTables\Editor\ValidateOptions;
    
          // Build our Editor instance and process the data coming from _POST
          Editor::inst( $db, 'new_recruited' )
              ->debug(true)
              ->fields(
                  Field::inst( 'new_recruited.first_name' )
                      ->validator( Validate::notEmpty( ValidateOptions::inst()
                          ->message( 'A first name is required' )
                      ) ),
                  Field::inst( 'new_recruited.last_name' )
                      ->validator( Validate::notEmpty( ValidateOptions::inst()
                          ->message( 'A last name is required' )
                      ) ),
                  Field::inst( 'new_recruited.meas_id' ),
                  Field::inst( 'mean.temp_day' ),
                  Field::inst( 'mean.temp_noon' )
              )
              ->leftJoin('measurements as mean', 'mean.id', '=', 'new_recruited.meas_id' )
              ->process( $_POST )
              ->json();
    
This discussion has been closed.