-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexc.php
95 lines (61 loc) · 1.34 KB
/
exc.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<?php
$name;
$text = "skdnsalkdnals";
$name = $text;
class Calcul{
public $name;
public function __construct($servername,$u,$p,$dbname=null)
{
$this->name = $text;
}
public function add($a,$b)
{
return $this->name;
}
public function sub($a,$b)
{
return $a-$b;
}
}
$servername = "localhost";
$username = "root";
$password = "123456";
$dbname = "php_work";
// Create connection
$conn = new mysqli($servername, $username, $password,$dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// $sql = "CREATE TABLE user (
// id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
// firstname VARCHAR(30) NOT NULL,
// lastname VARCHAR(30) NOT NULL,
// email VARCHAR(50)
// )";
// if( $conn->query($sql) ){
// echo 'User table ok';
// } else{
// echo "sorry";
// }
$id =3;
$sql = "select * from user where id=".$id;
$result = $conn->query($sql);
?>
<table border="1">
<thead>
<tr>
<td>first name</td>
<td>laste name</td>
<td>email</td>
</tr>
</thead>
<?php while( $raw = $result->fetch_assoc()){ ?>
<tr>
<td><?php echo $raw['firstname'] ?></td>
<td><?php echo $raw['lastname'] ?></td>
<td><?php echo $raw['email'] ?></td>
</tr>
<?php } ?>
</table>
<!-- <input type="text"> -->