Skip to content

Instantly share code, notes, and snippets.

@fadhil-riyanto
Created December 3, 2020 05:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fadhil-riyanto/00356287405336f0c617d9b00381516a to your computer and use it in GitHub Desktop.
Save fadhil-riyanto/00356287405336f0c617d9b00381516a to your computer and use it in GitHub Desktop.
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