Sunday, 12 March 2017

How to setup an if condition in the event no result is returned?

Good day,

I have the following query:

// Add email later on
let sqlSelectBoxInformation = "SELECT DISTINCT longestDimension, box_id from box WHERE occupied ='unoccupied'";

 connectionBoxInformation.query(sqlSelectBoxInformation, function(err, rows, fields) {

if (!err) {
  // Check to see if the user entered hashtag is found in the database
  // Create a variable to track if the item was found


        var data = {
         rows: rows,
         userHashtag: databaseHashtag
        }
        res.render('delivery/chooseBox', data);

       // Change the variable to true
       wasFound = true;

}

In the event that no results is returned because no result could satisfy those requirements, I would like to have an else statement that would render the user to another page, but I am not too sure how I would proceed.



via John

No comments:

Post a Comment