-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path3_1.php
58 lines (54 loc) · 1.04 KB
/
3_1.php
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
<?php
$conn = OpenCon();
$sql = "show tables";
$result = $conn->query($sql);
$table = mysqli_fetch_array($result);
function OpenCon()
{
$dbhost = "localhost";
$dbuser = "root";
$dbpass = "";
$db = "employees";
$conn = new mysqli($dbhost, $dbuser, $dbpass,$db) or die("Connect failed: %s\n". $conn -> error);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}else{
echo("oppkobling vellykket"."<br>");
}
return $conn;
}
function CloseCon($conn)
{
$conn -> close();
}
?>
<!DOCTYPE html>
<html>
<body>
<table border = '2'>
<tr>
<th>table</th>
<th>attributes</th>
</tr>
<?php
while ($table)
{
$sql1 = "show COLUMNS FROM $table[0]";
echo "<tr>";
echo "<td>" . "$table[0] <br>" ."</td>";
echo "<td>";
$result1 = $conn->query($sql1);
$collumnames = mysqli_fetch_array($result1);
while($collumnames){
print("$collumnames[0], ");
$collumnames = mysqli_fetch_array($result1);
}
echo "</td>";
echo "</tr>";
$table = mysqli_fetch_array($result);
}
$conn->close();
?>
</table>
</body>
</html>