-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathselectsDB.php
More file actions
57 lines (42 loc) · 1.75 KB
/
selectsDB.php
File metadata and controls
57 lines (42 loc) · 1.75 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
<?php
include "connection.php";
//Выводит список запросов
if($_POST['action'] == 'query') {
$sql = $_POST['sql'];
$result = mysqli_query($conn, $sql);
echo "<select name=querydb id=select autocomplete=off>";
while ($row = mysqli_fetch_assoc($result)) {
echo "<option id=option>" . $row['NameQuery'] . "</option>";
}
echo "</select>";
}
//Выводит список таблиц
if($_POST['action'] == 'tables') {
$sql = $_POST['sql'];
$result = mysqli_query($conn, $sql);
echo "<select name=querydb id=select autocomplete=off>";
while ($row = mysqli_fetch_assoc($result)) {
echo "<option id=option>" . $row['Tables_in_students'] . "</option>";
}
echo "</select>";
}
//Вывод столбцов таблицы
if($_POST['button'] == 'Генерировать SQL'){
$select = $_POST['select'];
$sql = "SELECT TableVar FROM `queryalgb` where NameQuery = '$select'";
$result = mysqli_query($conn, $sql);
$result_query = mysqli_fetch_assoc($result);
$array = explode(",", $result_query['TableVar']);
foreach ($array as $value) {
$name_tables = strtok($value,' ');
$word = substr($value, -1);
$sql1 = "SHOW COLUMNS FROM `$name_tables`";
$result1 = mysqli_query($conn,$sql1);
echo "<select name=name-columns id=select1 autocomplete=off>";
while($row = mysqli_fetch_array($result1)){
echo "<option id=option>" . $word. '.' . $row['Field'] . "</option>";
}
echo "</select>";
}
}
?>