-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadmin.js
64 lines (53 loc) · 1.55 KB
/
admin.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
var mysql = require('mysql');
var express = require('express');
const { response } = require('express');
var app = express();
app.get('/',function(request,response){
fetchData(response);
console.log('clicked 1 time');
// value();
});
var db = mysql.createConnection({
host: "localhost",
user: 'root',
password:"",
database: "upi"
});
var final;
function executeQuery(sql,cb){
db.query(sql,function(error,result,fields){
if(error) {throw error;}
cb(result);
})
}
function fetchData(response){
executeQuery("Select * from request_to_admin ",function(result){
final = result;
response.write('<table border = 2px ><tr>');
//heading
for(var column in result[0]){
response.write('<th><label>' + column + '</label></th>');
}
response.write('</tr>');
for(var row in result){
response.write('<tr>');
for(var column in result[row]){
if(column == 'status'){
response.write('<td> <label><a href = "conf.html">'+'verify it'+ '</a></label> </button></td>' )
function myFunction(){
console.log('clicl');
}
}
else {
response.write('<td><label>' + result[row][column] + '</label></td>')
}
}
response.write('</tr>');
}
response.end('</table>');
})
}
// function value(req,res){
// req.write('<input type = "number">input')
// }
module.exports = app;