如何从表JSon获取ID?

时间:2017-02-16 08:30:10

标签: php mysql json

这是我的代码表json:

<?php
    header('content-type:application/json');
    include '../koneksi.php';
    $select = mysql_query('select tb_menu.*, tb_stock.jumlah_stok from tb_menu INNER JOIN tb_stock
                    ON tb_menu.kategori_stok=tb_stock.kategori_stok');
    $row=array();
    while($row=mysql_fetch_array($select))  
    {
        $arrayx=array(  "nama_menu"=>$row['nama_menu'],
                    "jenis_menu"=>$row['jenis_menu'],
                    "harga"=>$row['harga_menu'],
                    "disc"=>$row['disc'],
                    "deskripsi"=>$row['detail_menu'],
                    "gambar"=>"<img class='img-rounded' src='images/$row[gambar_menu]' alt='gbr' width='120'>",
                    "jumlah_stok"=>$row['jumlah_stok'],
                    "input_jml"=>"<input type='number' min='1' max='50' class='form-control' id='input_jml' name='input_jml' />",
                    "ket"=>"<textarea class='form-control' id='ket' name='ket' placeholder='Keterangan ...'></textarea>"
        );
        $rows[] = $arrayx;
    }
    echo json_encode($rows);
?>

html代码:

<form action="proses_pemesanan_temp.php" method="post" enctype="multipart/form-data">
    <div class="panel-body">
        <table
            data-url="../tables/menu_user.php"  
            data-row-style="rowStyle" 
            data-toggle="table" 
            data-show-refresh="true" 
            data-show-toggle="true" 
            data-show-columns="true" 
            data-search="true" 
            data-select-item-name="toolbar1" 
            data-pagination="true" 
            data-sort-name="name" 
            data-sort-order="desc">
            <thead>
                <tr>
                    <th data-field="nama_menu" data-sortable="true" data-align="center">Nama Menu</th>
                    <th data-field="jenis_menu"  data-sortable="true" data-align="center">Jenis Menu</th>
                    <th data-field="harga" data-sortable="true" data-align="center">Harga</th>
                    <th data-field="disc" data-sortable="true" data-align="center">Disc(%)</th>
                    <th data-field="deskripsi" data-sortable="true" data-align="center">Deskripsi</th>
                    <th data-field="gambar" data-sortable="true" data-align="center">Gambar</th>
                    <th data-field="jumlah_stok" data-sortable="true" data-align="center">Sisa Stok</th>
                    <th data-field="input_jml" data-align="center">Jumlah</th>
                    <th data-field="ket" data-align="center">Keterangan</th>
                </tr>
            </thead>
            <tr>
            </tr>
        </table>
        <div align="center">
            <button class="btn btn-primary btn-lg " title="Tambah Data Menu" type="submit"> <span class="glyphicon glyphicon-shopping-cart"> TAMBAH </span></a>
        </div>

        <script>
            $(function () {
                $('#hover, #striped, #condensed').click(function () {
                    var classes = 'table';

                    if ($('#hover').prop('checked')) {
                        classes += ' table-hover';
                    }
                    if ($('#condensed').prop('checked')) {
                        classes += ' table-condensed';
                    }
                    $('#table-style').bootstrapTable('destroy')
                            .bootstrapTable({
                                classes: classes,
                                striped: $('#striped').prop('checked')
                            });
                });
            });

            function rowStyle(row, index) {
                var classes = ['info', 'info', 'info', 'info', 'info'];

                if (index % 2 === 0 && index / 2 < classes.length) {
                    return {
                        classes: classes[index / 2]
                    };
                }
                return {};
            }
        </script>
    </div>
</form>

我的问题:我怎样才能获得ID菜单? POST或GET会帮助我。感谢名单

0 个答案:

没有答案