-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadminTableAccordingToUser.php
More file actions
60 lines (53 loc) · 1.35 KB
/
adminTableAccordingToUser.php
File metadata and controls
60 lines (53 loc) · 1.35 KB
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
<?php
session_start();
$serverName = "127.0.0.1"; //serverName\instanceName
$userName = "root";
$password = "";
$i = 0;
while (1) {
if(isset($_POST['btn_'.$i.''])){
$database = $_POST['btn_'.$i.''];
$_SESSION['db'] = $_POST['btn_'.$i.''];
//echo $_SESSION['db'];
$msqlConn = mysqli_connect($serverName, $userName, $password, $database);
if($msqlConn ) {
echo "Connection established.<br />";
$tb_list = mysqli_query($msqlConn, "SHOW TABLES FROM ".$database);
?>
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>User's</title>
</head>
<body>
<form class="" action="adminTableShow.php" method="post">
<div id="buttos_panel">
<?php echo get_buttons($tb_list); ?>
</div>
</form>
</body>
</html>
<?php
}else{
echo "Connection could not be established.<br />";
die( print_r( sqlsrv_errors(), true));
}
break;
}
$i = $i + 1;
}
function get_buttons($db_list){
$str = "";
$i = 0;
$btns = array();
while ($row = mysqli_fetch_row($db_list)) {
$btns[$i] = $row[0];
$i++;
}
while (list($k, $v) = each($btns)) {
$str.= ' <input type="submit" value="'.$v.'" name="btn_'.$k.'" id="btn_'.$k.'"/>';
}
return $str;
}
?>