Answer the question
In order to leave comments, you need to log in
How to format data input and output correctly?
I have a local database and I need to send a request to enter data through textarea and vivisti data in the Chrome web program. The code of the query program is:
$(document).ready(function() {
$('#btn_submit').click(function(e) {
e.preventDefault();
//var input = $('#input').val();
var mysql = require("mysql");
var conn = mysql.createConnection({
host: "localhost",
database: "electronic_dictionary",
user: "admin",
password: "admin"
});
conn.connect(function(err) {
if (err) throw err;
console.log("Connected!");
});
const sql = "SELECT * FROM `tlum` WHERE `tlum_name` = ?";
const filter = $('#input').val();
conn.query(sql, filter, function (err, result) {
if(err) console.log(err);
console.log(result);
})
conn.end(err => {
if (err) throw err;
console.log("CLOSSED!");
})
<!DOCTYPE html>
<html>
<head>
<script src="jquery.js"></script>
<script src="Node.js"></script>
<title></title>
<meta charset="UTF-8">
<link rel="stylesheet" href="style.css">
</head>
<body>
<header>
<textarea id="input"></textarea>
<input id="btn_submit" type="submit"><br>
</header>
<article>
<div id="result" ></div>
</article>
<footer>
©
<span>2020</span>
Good Word Guide
</footer>
</div>
</body>
</html>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question