Script DataTable


JS

Script DataTable


ตัวอย่าง DataTable


<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/dt/dt-1.11.5/datatables.min.css" />
<table id="tblUser" width="90%">
    <thead>
        <tr>
            <th>หัวตาราง 1 1</th>
            <th>หัวตาราง 1 2</th>
            <th>หัวตาราง 1 3</th>
            <th>หัวตาราง 1 4</th>
            <th>หัวตาราง 1 5</th>
        </tr>
    </thead>
    <tbody>
        <?php
            for($i=2;$i<30;$i++){
        ?>
            <tr>
                <?php
                    for($j=1;$j<6;$j++){
                ?>
                    <td>เนื้อหา แถว <?php echo $i . " คอลัมน์ " . $j; ?></td>
                <?php
                    }
                ?>
            </tr>
        <?php
            }
        ?>
    </tbody>
</table>

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/v/dt/dt-1.11.5/datatables.min.js"></script>
<script>
    jQuery(document).ready(function($) {
        $('#tblUser').DataTable();
    } );

    function readURL(input) {
        if (input.files && input.files[0]) {
            var reader = new FileReader();

            reader.onload = function (e) {
                $('#blah').attr('src', e.target.result);
            }

            reader.readAsDataURL(input.files[0]);
        }
    }

    $("#data_news_img").change(function(){
        readURL(this);
    });
</script>