Question: I am trying to print a list from mysql table to express page.

app.js uses routes.js. there I have get for users profile page

```
//profile
app.get('/profile', isLoggedIn, function(req, res){
  var courses = [];
  connection.query('SELECT courseID FROM studentCourses WHERE userID = ?', [req.user], function(err, rows){
    for(var i=0; i<rows.length; i++){
      courses.push(rows[i]);
    }
    for(var j=0; j< courses.length; j++){
      connection.query('SELECT name FROM courses WHERE courseID = ?', [courses[j]], function(err, rows2){
        list = rows2[j];
      });
    }
  });

  res.render('profile', {
    user : req.user // get the user out of session and pass to template
  },
  {
    courses : list
  }
  );
});

```

my mysql tables

users:
id, username, password

courses:
id, name

studentCourses:
id, userid, courseid

I am trying to list all course names that a user with id 2 have for example.

Cant find a descent tutorial for nodejs and mysql.
This is as far as i could go but couldnt make it work.

Probably its just a wrong way.

Any help listing that table to a ejs web template would be nice.

Thanks

Answer: 
`x` in `main()` is a local variable that is *independent* from the `x` variable in `getheight()`. You are returning the new value from the latter but areignoring the returned value. Set `x` in `main` from the function call result:

```
while x not in range (1,23):
    x = getheight()
    if x in range (1,23):
        break

```

You also need to fix your `getheight()` function to return an *integer*, not a string:

```
def getheight():
    x = input("Give me a positive integer no more than 23 \n")
    return int(x)

```
Return does not mean that it will automatically update whatever variable name in main matches the return variable. If you do not store this return value, the return value will be gone. Hence you must do

```
x=getheight()

```

to update your variable x