lundi 30 novembre 2020

Display MySQL table data in web page

I have queried the database and want to display the data in the table on the dashboard web page.

const getData = () => {


        db.query('SELECT * FROM classes', async (error, results) => {
            if (error) {
                console.log(error);
    
            }
            else {
    
                console.log(results)
    
    
            }
        })
    
    }
    
    getData();

I am using nodejs and ejs. What would i need to add inside my dashboard page to get the data displayed in console.log to display on the web page instead.

Below is the current code for my dashboard page.

 <h1 class="text-center mb-3"><i class="fas fa-sign-in-alt"></i>Admin Dashboard</h1>
    <table class="table table-dark">
      <thead>
        <tr>
          <th scope="col"></th>
          <th scope="col">Student Name</th>
          <th scope="col">Gender</th>
          <th scope="col">Set</th>
          <th scope="col">Result</th>
        </tr>
      </thead>
    </table>



Aucun commentaire:

Enregistrer un commentaire