title: Server side pagination in node js using ejs Template and MYSQL
body: <p>As I have to render large data and when I am doing client-side pagination then it's taking time and I know Server side pagination is best for </p>
  
  <ul>
  <li>Large data set</li>
  <li>Faster initial page load</li>
  </ul>
  
  <p>But I don't have any idea how to do Server Side pagination using NODE.JS  EJS and MYSQL here is my Routes and.EJS</p>
  
  <p><strong>Routes</strong></p>
  
  <pre><code>app.get('/',function(req,res,next){
      req.getConnection(function(error, conn) {
          let sql = `SELECT *FROM studiestable
                     WHERE ReceivingDate &gt;= ( CURDATE() - INTERVAL 35 DAY )       
                     ORDER BY  Bckup DESC,
                     ReceivingDate DESC`;
  
          conn.query(sql,function(err,rows,fields){
              if (err) {
                  req.flash('error', err)
                  res.render('patient/dashboard', {
                      title: 'Dashboard', 
                      data: ''
                  })
              } else {
                  res.render('patient/dashboard', {
                      title: 'Dashboard', 
                      data: rows
                  })
              }
          })
      })
  })
  </code></pre>
  
  <p><strong>EJS</strong></p>
  
  <pre><code>&lt;table id="pattTab" class="table small"&gt;
              &lt;tr style="background-color: rgb(122, 135, 160);color: white"&gt; 
                  &lt;th&gt;ID&lt;/th&gt; 
                  &lt;th&gt;Patient Name&lt;/th&gt;               
                  &lt;th&gt;Age&lt;/th&gt;
                  &lt;th&gt;Modality&lt;/th&gt;                   
                  &lt;th&gt;Images&lt;/th&gt;                         
              &lt;/tr&gt;
              &lt;% if (data) { %&gt;
                  &lt;% data.forEach(function(Patient){ %&gt;
                      &lt;tr&gt;      
                          &lt;td&gt;&lt;%= Patient.PatientID %&gt;&lt;/td&gt;
                          &lt;td&gt;&lt;%= Patient.PatientName %&gt;&lt;/td&gt;                                   
                          &lt;td&gt;&lt;%= Patient.Age %&gt;&lt;/td&gt;
                          &lt;td&gt;&lt;%= Patient.Modality %&gt;&lt;/td&gt;                        
                          &lt;td&gt;&lt;%= Patient.Images %&gt;&lt;/td&gt;                                                     
                      &lt;/tr&gt;
                  &lt;% }) %&gt;
                  &lt;% } %&gt;        
          &lt;/table&gt;   
  </code></pre>