0

I firstly did the table layout and made sure everything is working, after connecting the table to a database and trying to put the records inside it, everything worked perfectly, but the class didnt, i have now the boring table without the layout made.

    <body>
     <h1>Employees</h1>
     <table class="responstable">
    <?php
    require 'connection.php';
    $conn    = Connect();



    $result = mysqli_query($conn,"SELECT * FROM employee");


    echo "<table border='1'>


      <tr>
        <th>Id</th>
        <th>First name</th>
        <th>Last name</th>
        <th>Salary</th>
        <th>Start Date</th>
        <th>Department</th>
      </tr>";


    while($row = mysqli_fetch_array($result))
    {
    echo "<tr>";
    echo "<td>" . $row['id'] . "</td>";
    echo "<td>" . $row['firstname'] . "</td>";
    echo "<td>" . $row['lastname'] . "</td>";
    echo "<td>" . $row['salary'] . "</td>";
    echo "<td>" . $row['startdate'] . "</td>";
    echo "<td>" . $row['department'] . "</td>";
    echo "</tr>";
    }
    echo "</table>";

    mysqli_close($conn);
    ?>



      <script src='http://cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.js'></script>


    </body>
    </html>

the table class is "responstable"

1 Answer 1

2

table tag is defined in 2 places.try removing this.

echo "<table border='1'>

or remove the table tag at the top after h1 tag and add the class to the table tag defined in the echo as, complete code

<body>
     <h1>Employees</h1>
    <?php
    require 'connection.php';
    $conn    = Connect();



    $result = mysqli_query($conn,"SELECT * FROM employee");


    echo "<table border='1' class='responstable'>


      <tr>
        <th>Id</th>
        <th>First name</th>
        <th>Last name</th>
        <th>Salary</th>
        <th>Start Date</th>
        <th>Department</th>
      </tr>";


    while($row = mysqli_fetch_array($result))
    {
    echo "<tr>";
    echo "<td>" . $row['id'] . "</td>";
    echo "<td>" . $row['firstname'] . "</td>";
    echo "<td>" . $row['lastname'] . "</td>";
    echo "<td>" . $row['salary'] . "</td>";
    echo "<td>" . $row['startdate'] . "</td>";
    echo "<td>" . $row['department'] . "</td>";
    echo "</tr>";
    }
    echo "</table>";

    mysqli_close($conn);
    ?>



      <script src='http://cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.js'></script>


    </body>
    </html>
Sign up to request clarification or add additional context in comments.

1 Comment

how dumb of me ! thank you ! will mark it as an answer when i can

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.