Created
December 3, 2020 05:33
-
-
Save fadhil-riyanto/00356287405336f0c617d9b00381516a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let mysql = require('mysql'); | |
var db = mysql.createConnection({ | |
host: 'localhost', | |
user: 'root', | |
password: 'root', | |
database: 'phpdasar' | |
}); | |
db.connect(function(err){ | |
if(err) throw err; | |
let sql = 'SELECT * FROM users'; | |
db.query(sql, function(err, result){ | |
if(err) throw err; | |
console.log(`ID \t NAME \t\t EMAIL \t\t NO_WHATSAPP`); | |
console.log(`----------------------------------------------------------`); | |
result.forEach(customer => { | |
console.log(`${customer.id} \t ${customer.name} \t ${customer.email} \t ${customer. no_whatsapp}`); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment