首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用php & mysql Ajax、Jsone显示公司详细信息

如何使用php & mysql Ajax、Jsone显示公司详细信息
EN

Stack Overflow用户
提问于 2019-05-21 09:59:04
回答 1查看 118关注 0票数 0

我需要知道产品的最后价格,当我最后一次使用PHP & Mysql,Ajax,Jsone给那家公司时。

这是MySQl的代码

代码语言:javascript
复制
SELECT tbl_order_item.order_id,tbl_order_item.item_name,tbl_order_item.order_item_price ,tbl_order.order_receiver_name FROM tbl_order_item INNER JOIN tbl_order ON tbl_order_item.order_id = tbl_order.order_id WHERE tbl_order.type="PROFORMA INVOICE"  GROUP BY tbl_order_item.item_name order BY tbl_order.order_receiver_name ASC

在Mysql后端我得到了结果,但是如何在车展前运行相同的进程呢?我的数据库

EN

回答 1

Stack Overflow用户

发布于 2019-05-21 10:05:14

我在product上试过,但我只得到了一个产品名称,只有我的代码在这里 index.php script

代码语言:javascript
复制
 <script type="text/javascript">
    $(document).ready(function(){

        $(document).on('keydown', '.orderreceiver', function() {

            var id = this.id;
            var splitid = id.split('_');
            var index = splitid[1];

            $( '#'+id ).autocomplete({
                source: function( request, response ) {
                    $.ajax({
                        url: "get_cprice.php",
                        type: 'post',
                        dataType: "json",
                        data: {
                            search: request.term,request:1
                        },
                        success: function( data ) {
                            response( data );
                        }
                    });
                },
                select: function (event, ui) {
                    $(this).val(ui.item.label); // display the selected text
                    var userid = ui.item.value; // selected id to input

                    // AJAX
                    $.ajax({
                        url: 'get_cprice.php',
                        type: 'post',
                        data: {userid:userid,request:2},
                        dataType: 'json',
                        success:function(response){

                            var len = response.length;

                            if(len > 0){
                                var id = response[0]['id'];
                                var itemname = response[0]['itemname'];
                                //var description = response[0]['description'];
                                //var suom = response[0]['suom'];
                                //var cost = response[0]['cost'];
                                //var stock = response[0]['stock'];
                                //var category = response[0]['category'];

                                document.getElementById('itemname_'+index).value = itemname;
                                //document.getElementById('description_'+index).value = description;
                                //document.getElementById('suom_'+index).value = suom;
                                //document.getElementById('cost_'+index).value = cost;
                                //document.getElementById('stock_'+index).value = stock;
                                //document.getElementById('category_'+index).value = category;

                            }

                        }
                    });

                    return false;
                }
            });
        });

        // Add more
        $('#addmore').click(function(){

            // Get last id 
            var lastname_id = $('.tr_input input[type=text]:nth-child(1)').last().attr('id');
            var split_id = lastname_id.split('_');

            // New index
            var index = Number(split_id[1]) + 1;

            // Create row with input elements
            var html = "<tr class='tr_input'><td><input type='text' class='orderreceiver' id='orderreceiver_"+index+"' placeholder=''></td><input type='text' class='itemname' id='itemname_"+index+"'></td></tr>";

            // Append data
            $('tbody').append(html);

        });
    });

</script>

结果单个公司项目只显示一个问题 在这里输入图像描述

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56235782

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档