title: Fetch records from mysql to a form with nodejs(expressjs)
body: <p>Want to fetch records from mysql to a web form so that user can make changes and update it. Am fetching the records from different tables in the database.</p>
  
  <p><strong>update.js</strong></p>
  
  <pre><code>    var express = require('express');
      var router = express.Router();
      var db     = require('./../db');
  
      router.get('/', function(req, res, next) {
        db.select('*').from('student').then(function(rows){
              res.render('update-student',{title:'Update Student',data:rows})
          });
      });
  
    router.get('/', function(req, res, next) {
        db.select('*').from('category').then(function(result){
              res.render('update-student',{title:'Update Student',edata:result})
          });
      });
  
      module.exports = router;
  </code></pre>
  
  <p><strong>update_student.ejs</strong></p>
  
  <pre><code>&lt;select&gt;
        &lt;option&gt;&lt;/option&gt;
        &lt;% for (var i = 0; i &lt; data.length; i++) {%&gt;
       &lt;option value=""&gt;&lt;%= data[i].gender; %&gt;&lt;/option&gt;
          &lt;% }%&gt;
   &lt;/select&gt;
  
  &lt;select&gt;
        &lt;option&gt;&lt;/option&gt;
        &lt;% for (var i = 0; i &lt; edata.length; i++) {%&gt;
       &lt;option value=""&gt;&lt;%= edata[i].cat_name; %&gt;&lt;/option&gt;
          &lt;% }%&gt;
   &lt;/select&gt;
  </code></pre>
  
  <p>I had this erorr "<strong>edata is not defined</strong>"   </p>
  
  <p>Please any help</p>