我不能让Slickgrid显示mySql数据

时间:2013-11-19 12:40:16

标签: javascript php jquery mysql slickgrid

当我运行它时,它只显示html表。我哪里错了。我已经尝试了很多没有成功的例子,并且在上周的网上尽可能多地阅读。我认为php数组没有正确传递给javascript。先感谢您。

Eamon Byrne

<html>

    <head>
        <title>Php using database</title>
        <link rel="stylesheet" href="css/slick.grid.css" type="text/css" media="screen" charset="utf-8" />
        <link rel="stylesheet" href="css/smoothness/jquery-ui-1.8.5.custom.css" type="text/css" media="screen" charset="utf-8" />
        <link rel="stylesheet" href="css/examples.css" type="text/css" media="screen" charset="utf-8" />
    </head>

    <body>
        <center>
             <h1>Database Connection</h1>

        </center>
        <?php include( 'inc/dbConnect.php'); ?>
        <?php connectDB(); $i=0; $query="SELECT media_id, name, location, jobs_day, phone FROM allprintmedia" ; $result=m ysql_query($query) or die( "Query failed"); $array=m ysql_fetch_array($result) ; ?>
        <div id="table_admin" class="span7">
             <h3>Print Media</h3>

            <table border="1" class="table" id="media">
                <thead>
                    <tr>
                        <th>ID</th>
                        <th>Name</th>
                        <th>Location</th>
                        <th>Day</th>
                        <th>Phone</th>
                    </tr>
                </thead>
                <?php $count=0; while ($row=m ysql_fetch_array($result)) { $arr[$count]=$ row; $count++; echo "<TR>"; echo "<TD>", $row[ 'media_id'], "  </TD><TD>", $row[ 'name'], "  </TD><TD>", $row[ 'location'], "  </TD><TD>", $row[ 'jobs_day'], "  </TD><TD>", $row[ 'phone'], "<tr>"; echo "</TR>"; } ?>
                <script src="js/jquery-1.10.2.min.js"></script>
                <script src="js/jquery.event.drag-2.0.min.js"></script>
                <script src="js/slick.core.js"></script>
                <script src="js/slick.grid.js"></script>
                <script>
                    $(document).ready(function() {
                        var oTable = $('#media').jquery.dataTable;
                        $('td', oTable.fnGetNodes()).jquery.editable('php/editable_ajax.php', {
                            "callback": function(xValue, y) {
                                var aPos = oTable.fnGetPosition(this);
                                oTable.fnUpdate(sValue, aPos[0], aPos[1]);
                            },
                                "submitdata": function(value, settings) {
                                return {
                                    "row_id": this.parentNode.getAttribute('id'),
                                        "column": oTable.fnGetPosition(this)[2]
                                };
                            },
                                "height": "14px"
                        });
                    });
                </script>
                </thead>
    </body>

</html>

1 个答案:

答案 0 :(得分:0)

首先请不要使用mysql_query(),因为它是depreciated ...而是使用PDOmysli - 这些链接将带您进入一些教程。

<?php connectDB(); $i=0; $query="SELECT media_id, name, location, jobs_day, phone FROM allprintmedia" ; $result=m ysql_query($query) or die( "Query failed"); $array=m ysql_fetch_array($result) ; ?>

<?php $count=0; while ($row=m ysql_fetch_array($result)) { $arr[$count]=$ row; $count++; echo "<TR>"; echo "<TD>", $row[ 'media_id'], "  </TD><TD>", $row[ 'name'], "  </TD><TD>", $row[ 'location'], "  </TD><TD>", $row[ 'jobs_day'], "  </TD><TD>", $row[ 'phone'], "<tr>"; echo "</TR>"; } ?>

仔细查看这些行,而不是

 $result=mysql_query($query) 
你有:

$result=m ysql_query($query)

这适用于所有外观。这可能是一个错字吗?