I am working on a project attendance system and i want to access a variable that is declared in php file require.php in my node.js file custom.js how should i achieve that? so far i have created a connection with my sql server and hard-coded the value of
`var company_name="Aaqoo 2";`
and everything is working fine but i dont want to hard-code it i want to fetch the company_name stored in my php variable $sup_company_name which is declared in my require.php file so my question is how should i fetch the value from $sup_company_name in my js variable.....kindly help me then i will ask futher questions
this is my node js code
var express = require('express');
var mysql = require('mysql');
var app = express();
var connection = mysql.createConnection({
host:'localhost',
user:'root',
password:'',
database:'attendance'
});
connection.connect(function(error) {
if (!!error) {
console.log('Error in connection');
} else {
console.log('Connected');
}
});
var company_name = "Aaqoo 2"; //here i want the value from php variable $sup_company_name;
connection.query("Select * from employee_leaves where employee_leave_company_name=?", [company_name], function(error,rows,fields) {
if (!!error) {
console.log("Error in the query");
} else {
console.log("succesfully done\n");
console.log(rows);
}
});
app.listen(1337);