0

I have tried this before with a different database and worked well, but with this database it's not working. I have the following html file:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <link rel="shortcut icon" type="image/ico" href="http://www.datatables.net/favicon.ico">
    <meta name="viewport" content="initial-scale=1.0, maximum-scale=2.0">

    <title>DataTables example - Zero configuration</title>
    <link rel="stylesheet" type="text/css" href="dt/jquery.dataTables.css">
    <link rel="stylesheet" type="text/css" href="dt/shCore.css">
    <link rel="stylesheet" type="text/css" href="dt/demo.css">
    <style type="text/css" class="init">

    </style>

    <script type="text/javascript" language="javascript" src="dt/jquery.js"></script>
    <script type="text/javascript" language="javascript" src="dt/jquery.dataTables.js"></script>
    <script type="text/javascript" language="javascript" src="dt/shCore.js"></script>
    <script type="text/javascript" language="javascript" src="dt/demo.js"></script>
    <script type="text/javascript" language="javascript" class="init">







$(document).ready(function() {
    $('#example').dataTable();
} );


    </script>
</head>

<body>



<table id="example" class="display" cellspacing="0" width="100%">

<thead>
                    <tr>
                        <th>Shopfloor</th>
                        <th>Cell</th>
                        <th>Line</th>
                        <th>Machine Section</th>
                        <th>Station</th>
                        <th>Technician</th>
                        <th>Date</th>
                        <th>Time</th>
                        <th>Intervention</th>
                    </tr>
                </thead>

                <tfoot>
                    <tr>
                        <th>Shopfloor</th>
                        <th>Cell</th>
                        <th>Line</th>
                        <th>Machine Section</th>
                        <th>Station</th>
                        <th>Technician</th>
                        <th>Date</th>
                        <th>Time</th>
                        <th>Intervention</th>
                    </tr>
                </tfoot>

                <tbody>


<?php
 $con = mysql_connect("10.1.68.12","xxxxx","xxxx");
mysql_select_db("tpm", $con);



$result = mysql_query ("SELECT * FROM dbo_shopfloorcells INNER JOIN (dbo_noted_by INNER JOIN (dbo_leader_name INNER JOIN (dbo_Station INNER JOIN (dbo_Shop_Floor INNER JOIN (dbo_Fault_Desc INNER JOIN 
(dbo_Machine INNER JOIN (dbo_Line_Cell_Binding INNER JOIN (dbo_Tech_Name INNER JOIN (dbo_Maint_Category INNER JOIN dbo_newprevlog2 ON dbo_Maint_Category.ID = dbo_newprevlog2.ID_Maint_Cat) 
ON dbo_Tech_Name.ID = dbo_newprevlog2.ID_Tech_Name) ON dbo_Line_Cell_Binding.PKID = dbo_newprevlog2.ID_Line_Desc) ON dbo_Machine.PKID = dbo_newprevlog2.ID_Mach_Desc) 
ON dbo_Fault_Desc.ID = dbo_newprevlog2.ID_Fault_Desc) ON dbo_Shop_Floor.ID = dbo_newprevlog2.ID_Shop_Floor) ON dbo_Station.PKID = dbo_newprevlog2.ID_Station_No) 
ON dbo_leader_name.ID = dbo_newprevlog2.ID_Leader_Name) ON dbo_noted_by.ID = dbo_newprevlog2.ID_Noted_By) ON (dbo_shopfloorcells.PKID = dbo_Line_Cell_Binding.ID_Cell_Shop_Floor) 
AND (dbo_shopfloorcells.ID_Shop_Floor = dbo_Shop_Floor.ID)GROUP BY dbo_newprevlog2.ID, dbo_newprevlog2.Status, dbo_Shop_Floor.Shopfloor, dbo_shopfloorcells.Cell, dbo_Line_Cell_Binding.Line_Name, 
dbo_Machine.Machine_Section, dbo_Station.Station_, dbo_Tech_Name.Technician_Name, dbo_Maint_Category.Maintenance_Category, dbo_Fault_Desc.Fault_Description, 
dbo_newprevlog2.Intervention, dbo_newprevlog2.Remarks, dbo_newprevlog2.ComponentsParts, dbo_newprevlog2.StartDate1, dbo_newprevlog2.EndDate1, dbo_newprevlog2.StartTime1, 
dbo_newprevlog2.EndTime1, dbo_newprevlog2.DurationTime, dbo_newprevlog2.ID_Shop_Floor, dbo_Line_Cell_Binding.ID_Cell_Shop_Floor");


while ($row = mysql_fetch_array($result))
{

  echo "<tr>";

  echo "<td>" . $row['Shopfloor'] . "</td>";  
  echo "<td>" . $row['Cell'] . "</td>";
  echo "<td>" . $row['Line_Name'] . "</td>";
  echo "<td>" . $row['Machine_Section'] . "</td>";
  echo "<td>" . $row['Station'] . "</td>";
  echo "<td>" . $row['Technician_Name'] . "</td>";
  echo "<td>" . $row['StartDate1'] . "</td>";
  echo "<td>" . $row['StartTime1'] . "</td>";
  echo "<td>" . $row['Intervention'] . "</td>";

  echo "</tr>";


}

mysql_close($con);
?>  
</tr>

                </tbody>
            </table>


</body>

</html>

For some reason the page does not display correctly and it does not show the results. The links are well referenced since I tried it with zero_configuration.html but the page displays the table layout with

" . $row['Shopfloor'] . " " . $row['Cell'] . " " . $row['Line_Name'] . " " . $row['Machine_Section'] . " " . $row['Station'] . " " . $row['Technician_Name'] . " " . $row['StartDate1'] . "

where supposed to be the results of the query. What am I missing please? thanks

1 Answer 1

0

elstiv, can you try with the code below. It will show you error if db is not connected or problem in query.

$con = mysql_connect("10.1.68.12","xxxxx","xxxx");
if (!$con){
  die('Could not connect: ' . mysql_error());
}

$db_selected = mysql_select_db("tpm",$con);

$sql = "SELECT * FROM dbo_shopfloorcells INNER JOIN (dbo_noted_by INNER JOIN (dbo_leader_name INNER JOIN (dbo_Station INNER JOIN (dbo_Shop_Floor INNER JOIN (dbo_Fault_Desc INNER JOIN 
(dbo_Machine INNER JOIN (dbo_Line_Cell_Binding INNER JOIN (dbo_Tech_Name INNER JOIN (dbo_Maint_Category INNER JOIN dbo_newprevlog2 ON dbo_Maint_Category.ID = dbo_newprevlog2.ID_Maint_Cat) 
ON dbo_Tech_Name.ID = dbo_newprevlog2.ID_Tech_Name) ON dbo_Line_Cell_Binding.PKID = dbo_newprevlog2.ID_Line_Desc) ON dbo_Machine.PKID = dbo_newprevlog2.ID_Mach_Desc) 
ON dbo_Fault_Desc.ID = dbo_newprevlog2.ID_Fault_Desc) ON dbo_Shop_Floor.ID = dbo_newprevlog2.ID_Shop_Floor) ON dbo_Station.PKID = dbo_newprevlog2.ID_Station_No) 
ON dbo_leader_name.ID = dbo_newprevlog2.ID_Leader_Name) ON dbo_noted_by.ID = dbo_newprevlog2.ID_Noted_By) ON (dbo_shopfloorcells.PKID = dbo_Line_Cell_Binding.ID_Cell_Shop_Floor) 
AND (dbo_shopfloorcells.ID_Shop_Floor = dbo_Shop_Floor.ID)GROUP BY dbo_newprevlog2.ID, dbo_newprevlog2.Status, dbo_Shop_Floor.Shopfloor, dbo_shopfloorcells.Cell, dbo_Line_Cell_Binding.Line_Name, 
dbo_Machine.Machine_Section, dbo_Station.Station_, dbo_Tech_Name.Technician_Name, dbo_Maint_Category.Maintenance_Category, dbo_Fault_Desc.Fault_Description, 
dbo_newprevlog2.Intervention, dbo_newprevlog2.Remarks, dbo_newprevlog2.ComponentsParts, dbo_newprevlog2.StartDate1, dbo_newprevlog2.EndDate1, dbo_newprevlog2.StartTime1, 
dbo_newprevlog2.EndTime1, dbo_newprevlog2.DurationTime, dbo_newprevlog2.ID_Shop_Floor, dbo_Line_Cell_Binding.ID_Cell_Shop_Floor";

$result = mysql_query($sql,$con) or die(mysql_error());
while ($row = mysql_fetch_array($result)){
      echo $row['Shopfloor'];

}

it's would be better to use mysqli instead of mysql because mysqli is the future ready....

3
  • Thanks, the funny details have now disappeared but the table is showing 'No data available in table.' Very strange because I tested the SQL query and it works...
    – elstiv
    Commented Sep 3, 2014 at 13:51
  • Do you think i ought to change the extension of the file from html to php? wold that make a difference?
    – elstiv
    Commented Sep 4, 2014 at 5:01
  • yes, you need to change the extension html to php to run php code.
    – Ram Sharma
    Commented Sep 4, 2014 at 5:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.