0

When I run this it just displays the html table. Where am I going wrong. I have tried quite a few examples with no success and have read as much as I could on the net in the last week. I think the php array is not getting passed correctly to the javascript. Thank you in advance.

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>
Tushar Gupta - curioustushar
  • 58,085
  • 24
  • 103
  • 107

1 Answers1

0

first off please do not use mysql_query(), as it has be depreciated... Rather use PDO or mysli- these links will take you to some tutorials.

<?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>"; } ?>

look closely these lines you have instead of

 $result=mysql_query($query) 

you have:

$result=m ysql_query($query)

this is for all appearances. Is this a typo maybe?

Community
  • 1
  • 1
Renier
  • 1,523
  • 4
  • 32
  • 60