How datatable import from xml file

How datatable import from xml file

Farid007Farid007 Posts: 30Questions: 2Answers: 0
edited January 2023 in Free community support
<!DOCTYPE html>
<html>
<head>
<link
rel="stylesheet"
type="text/css"
href="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/css/jquery.dataTables.css"
/>
</head>
<body>
<table id="table_id">
    <thead>
        <tr>
            <th style="width:15%">Unit</th>
            <th style="width:9%">Order Date</th style="width:7%">
            <th style="width:8%">Order# </th>
            <th style="width:12%">Customer</th>
            <th style="width:20%">Deliver To</th style="width:7%">
            <th style="width:10%">OGP#/Date</th>
            <th style="width:5%">Driver/Cell#/Vehicle#/bilty</th>
            <th style="width:7%">Carriage/CarriageBy</th>

        </tr>
    </thead>
<tbody>
<?xml version="1.0" encoding="UTF-8"?>
<?php
include("inc/config.php");
@$wh_id = $_GET['wh_id'];
@$option = $_GET['option_id'];
$where = '';
$where2 = '';
if ($wh_id > 0)
    $where =  ' and o.wh_id = ' . $wh_id;
else
    $where = '';
if ($option == 0)
    $where2 = '';
elseif ($option == 1)
    $where2 = ' and ogp.ogp_num is null ';
elseif ($option == 2)
    $where2 = ' and ogp.ogp_num is not null';
    $sql = "SELECT w.wh_name, o.o_date, o.o_num, ch.ch_desc as cust_name, o.o_delieverto, ogp.ogp_num, 
                       ogp.ogp_vehiclenum,ogp.ogp_date, ogp.ogp_driver, ogp.ogp_drivercell, ogp.ogp_biltynum, ogp.ogp_carriage, 
                       ogp.ogp_carriageby
                FROM k_order as o 
                        left outer join k_ogp    as ogp on o.o_num     = ogp.o_num 
                        inner join      a_chart  as ch  on o.ch_code   = ch.ch_code 
                        left outer join a_chart  as chd on o.ch_code_d = chd.ch_code 
                        inner join      i_whouse as w   on o.wh_id     = w.wh_id 
                " . $where . $where2 . "
                    order by o.o_date";
    $result = mysqli_query($conn, $sql) or die("error");
    if (mysqli_num_rows($result) > 0) {
        while ($row = mysqli_fetch_assoc($result)) {
            $color = $row['ogp_num'] <> "" ? "Green" : ($row['ogp_num'] == "" ?  "red" : "yellow");
    ?>
            <tr>
                <td><?= $row['wh_name'] ?></td>
                <td><?= $row['o_date'] ?></td>
                <td style="color:white"><span <?php echo "style=background-color:" . $color . "" ?>><?= $row['o_num'] ?></span></td>
                <td><?= $row['cust_name'] ?></td>
                <td><?php echo nl2br($row['o_delieverto']) ?></td>
                <td><?= $row['ogp_num'] ?><br><?= $row['ogp_date'] ?></td>
                <td><?= $row['ogp_driver'] ?><br><?= $row['ogp_drivercell'] ?><br><?= $row['ogp_vehiclenum'] ?>
                    <?php
                    if ($row['ogp_biltynum'] <> "") {
                        echo "<br>Bilty#" . $row['ogp_biltynum'] . "<br>";
                    }
                    ?>
                </td>
                <?php
                if ($row['ogp_carriageby'] == "c") {
                    $carriage = "Paid by Customer";
                } else if ($row['ogp_carriageby'] == "m") {
                    $carriage = "Paid by Company";
                } else {
                    $carriage = "";
                }
                echo "<td>" . $row['ogp_carriage'] . "<br>" . $carriage . "</td>";
                ?>
            </tr>
    <?php
        }
    }
    ?>
</table>
<script
type="text/javascript"
charset="utf8"
src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.2.min.js"
></script>
<script
type="text/javascript"
charset="utf8"
src="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/jquery.dataTables.min.js"></script>
<script>
$(function() {
$("#table_id").dataTable();
});
</script>
</body>
</html>

Oncall its features not show

Edited by Kevin: Syntax highlighting. Details on how to highlight code using markdown can be found in this guide

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,328Questions: 26Answers: 4,949
    Answer ✓

    I thin you will want to use the $(document).ready() event to wait to initialize Datatables until after the table is built.

    $(document).ready( function () {
      $("#table_id").dataTable();
    } );
    

    Kevin

  • Farid007Farid007 Posts: 30Questions: 2Answers: 0
    edited January 2023

    no its features not move only data move after call
    its xml file

Sign In or Register to comment.