Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

196
Views
Importing value from MySQL into JavaScript as variable

I'm trying to make a Database for a film distrubution. i got 3 tables: client, movies and borrowing and I want to get the price value from the movies table and multiply it with the days rented to get the final costs for borrowing it for x days. How can i import the value of the price and calculate with it? i got:

app.get("/ausleihen/get/kosten", function(req,res) {
const moviename= req.body.filmName;
const sqlGet = "SELECT costs FROM movies WHERE moviename=  ?;"
connection.query(sqlGet, moviename, (err, result) =>{
    varCosts=result;
});

});

app.post("/ausleihen/insert", (req, res)=>{

const prename= req.body.prename;
const lastname= req.body.lastname;
const moeviename= req.body.moeviename;
const begin= req.body.begin;
const end= req.body.end;
const begin1= new Date(req.body.begin).valueOf();
const end1= new Date(req.body.end).valueOf();

const diff = Math.abs(end1-begin1);
const diffDays = Math.ceil(diff / (1000*60*60*24));
const costs= diffDays;



const sqlInsert = "INSERT INTO ausleihen (moviename, prename, lastname, begin, end, costs) VALUES (?,?,?,moviename, prename, lastname, begin, end, costs], (err, result)=>{
    console.log(err);
})

});

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!