id: 1 - Name: Don James
id: 2 - Name: Don Doe
id: 4 - Name: John Doe
id: 6 - Name: Daisy Duck
id: 7 - Name: Julie Dooley
id: 8 - Name: Bob Marley
id: 9 - Name: Rita Marley
id: 10 - Name: Peter Tosh
id: 11 - Name: Tom Cat
id: 12 - Name: Woody Woodpecker
id: 13 - Name: Mighty Mouse
id: 14 - Name: Bob Marley
id: 15 - Name: Rita Marley
id: 16 - Name: Peter Tosh
id: 17 - Name: Tom Cat
id: 18 - Name: Woody Woodpecker
id: 19 - Name: Mighty Mouse
id: 20 - Name: John Deere
id: 21 - Name: Don James
id: 22 - Name: Donald Duck
id: 23 - Name: Daisy Duck
id: 24 - Name: Julie Dooley
id: 25 - Name: John Deer
id: 26 - Name: Don James
id: 27 - Name: John Deer
id: 28 - Name: John Deere
id: 29 - Name: John Deer
id: 30 - Name: Don James
id: 31 - Name: Donald Duck
id: 32 - Name: Daisy Duck
id: 33 - Name: Julie Dooley
id: 34 - Name: Tom Cat
id: 35 - Name: Woody Woodpecker
id: 36 - Name: Mighty Mouse
id: 37 - Name: Bob Marley
id: 38 - Name: Rita Marley
id: 39 - Name: Peter Tosh
id: 40 - Name: Don James
id: 41 - Name: Don James
id: 42 - Name: John Deer
id: 43 - Name: John Deere
id: 44 - Name: Don James
id: 45 - Name: Donald Duck
id: 46 - Name: Daisy Duck
id: 47 - Name: Julie Dooley
id: 48 - Name: Tom Cat
id: 49 - Name: Woody Woodpecker
id: 50 - Name: Mighty Mouse
id: 51 - Name: Bob Marley
id: 52 - Name: Rita Marley
id: 53 - Name: Peter Tosh
id: 54 - Name: John Deer
id: 55 - Name: John Deere
id: 56 - Name: Don James
id: 57 - Name: Don James
id: 58 - Name: Tom Cat
id: 59 - Name: Woody Woodpecker
id: 60 - Name: Mighty Mouse
id: 61 - Name: Donald Duck
id: 62 - Name: Daisy Duck
id: 63 - Name: Julie Dooley
id: 64 - Name: Bob Marley
id: 65 - Name: Rita Marley
id: 66 - Name: Peter Tosh
id: 67 - Name: John Deer
id: 68 - Name: John Deere
id: 69 - Name: Bob Marley
id: 70 - Name: Rita Marley
id: 71 - Name: Peter Tosh
id: 72 - Name: Donald Duck
id: 73 - Name: Daisy Duck
id: 74 - Name: Julie Dooley
id: 75 - Name: John Deere
id: 76 - Name: Tom Cat
id: 77 - Name: Woody Woodpecker
id: 78 - Name: Mighty Mouse
id: 79 - Name: Don James
id: 80 - Name: Bob Marley
id: 81 - Name: Rita Marley
id: 82 - Name: Peter Tosh
id: 83 - Name: John Deer
id: 84 - Name: Don James
id: 85 - Name: John Deer
id: 86 - Name: John Deere
id: 87 - Name: Don James
id: 88 - Name: Don James
id: 89 - Name: Tom Cat
id: 90 - Name: Woody Woodpecker
id: 91 - Name: Mighty Mouse
id: 92 - Name: Donald Duck
id: 93 - Name: Daisy Duck
id: 94 - Name: Julie Dooley
id: 95 - Name: Bob Marley
id: 96 - Name: Rita Marley
id: 97 - Name: Peter Tosh
id: 98 - Name: Tom Cat
id: 99 - Name: Woody Woodpecker
id: 100 - Name: Mighty Mouse
id: 101 - Name: Don James
id: 102 - Name: Bob Marley
id: 103 - Name: Rita Marley
id: 104 - Name: Peter Tosh
id: 105 - Name: John Deer
id: 106 - Name: John Deere
id: 107 - Name: Don James
id: 108 - Name: Donald Duck
id: 109 - Name: Daisy Duck
id: 110 - Name: Julie Dooley
id: 111 - Name: Bob Marley
id: 112 - Name: Rita Marley
id: 113 - Name: Peter Tosh
id: 114 - Name: Tom Cat
id: 115 - Name: Woody Woodpecker
id: 116 - Name: Mighty Mouse
id: 117 - Name: John Deere
id: 118 - Name: Don James
id: 119 - Name: Donald Duck
id: 120 - Name: Daisy Duck
id: 121 - Name: Julie Dooley
id: 122 - Name: John Deer
id: 123 - Name: Don James
id: 124 - Name: Bob Marley
id: 125 - Name: Rita Marley
id: 126 - Name: Peter Tosh
id: 127 - Name: Don James
id: 128 - Name: Donald Duck
id: 129 - Name: Daisy Duck
id: 130 - Name: Julie Dooley
id: 131 - Name: Don James
id: 132 - Name: John Deere
id: 133 - Name: Tom Cat
id: 134 - Name: Woody Woodpecker
id: 135 - Name: Mighty Mouse
id: 136 - Name: John Deer
id: 137 - Name: Don James
id: 138 - Name: Bob Marley
id: 139 - Name: Rita Marley
id: 140 - Name: Peter Tosh
id: 141 - Name: John Deere
id: 142 - Name: Tom Cat
id: 143 - Name: Woody Woodpecker
id: 144 - Name: Mighty Mouse
id: 145 - Name: Donald Duck
id: 146 - Name: Daisy Duck
id: 147 - Name: Julie Dooley
id: 148 - Name: Don James
id: 149 - Name: Don James
id: 150 - Name: Bob Marley
id: 151 - Name: Rita Marley
id: 152 - Name: Peter Tosh
id: 153 - Name: John Deer
id: 154 - Name: John Deere
id: 155 - Name: Tom Cat
id: 156 - Name: Woody Woodpecker
id: 157 - Name: Mighty Mouse
id: 158 - Name: Donald Duck
id: 159 - Name: Daisy Duck
id: 160 - Name: Julie Dooley
id: 161 - Name: Don James
id: 162 - Name: John Deer
id: 163 - Name: John Deere
id: 164 - Name: Don James
id: 165 - Name: Bob Marley
id: 166 - Name: Rita Marley
id: 167 - Name: Peter Tosh
id: 168 - Name: Tom Cat
id: 169 - Name: Woody Woodpecker
id: 170 - Name: Mighty Mouse
id: 171 - Name: Don James
id: 172 - Name: Donald Duck
id: 173 - Name: Daisy Duck
id: 174 - Name: Julie Dooley
id: 175 - Name: Tom Cat
id: 176 - Name: Woody Woodpecker
id: 177 - Name: Mighty Mouse
id: 178 - Name: John Deer
id: 179 - Name: John Deere
id: 180 - Name: Donald Duck
id: 181 - Name: Daisy Duck
id: 182 - Name: Julie Dooley
id: 183 - Name: Don James
id: 184 - Name: Bob Marley
id: 185 - Name: Rita Marley
id: 186 - Name: Peter Tosh
id: 187 - Name: Don James
id: 188 - Name: Donald Duck
id: 189 - Name: Daisy Duck
id: 190 - Name: Julie Dooley
id: 191 - Name: Don James
id: 192 - Name: Tom Cat
id: 193 - Name: Woody Woodpecker
id: 194 - Name: Mighty Mouse
Here is the code for accessing the database and display the information.
<?php $servername = "localhost"; $username = "username"; $password = "password"; $dbname = "DBname"; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $sql = "SELECT id, firstname, lastname FROM MyGuests"; $result = $conn->query($sql); if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { echo "<p>" echo "id: ". $row["id"]. " - Name: ". $row["firstname"]. " " . $row["lastname"] . "<br>"; echo "</p>"; } } else { echo "<p>0 results</p>"; } $conn->close(); ?>
Same example as above but displayed in a table.
ID | Name | |
---|---|---|
1 | Don James | john@example.com |
2 | Don Doe | john@example.com |
4 | John Doe | john@deere.net |
6 | Daisy Duck | daisyduck@example.com |
7 | Julie Dooley | juliedooley@example.com |
8 | Bob Marley | bobmarley@example.com |
9 | Rita Marley | ritamarley@example.com |
10 | Peter Tosh | petertosh@example.com |
11 | Tom Cat | tc@example.com |
12 | Woody Woodpecker | woody@example.com |
13 | Mighty Mouse | mighty@example.com |
14 | Bob Marley | bobmarley@example.com |
15 | Rita Marley | ritamarley@example.com |
16 | Peter Tosh | petertosh@example.com |
17 | Tom Cat | tc@example.com |
18 | Woody Woodpecker | woody@example.com |
19 | Mighty Mouse | mighty@example.com |
20 | John Deere | john@deere.net |
21 | Don James | john@example.com |
22 | Donald Duck | dduckn@example.com |
23 | Daisy Duck | daisyduck@example.com |
24 | Julie Dooley | juliedooley@example.com |
25 | John Deer | johnd@example.com |
26 | Don James | john@example.com |
27 | John Deer | johnd@example.com |
28 | John Deere | john@deere.net |
29 | John Deer | johnd@example.com |
30 | Don James | john@example.com |
31 | Donald Duck | dduckn@example.com |
32 | Daisy Duck | daisyduck@example.com |
33 | Julie Dooley | juliedooley@example.com |
34 | Tom Cat | tc@example.com |
35 | Woody Woodpecker | woody@example.com |
36 | Mighty Mouse | mighty@example.com |
37 | Bob Marley | bobmarley@example.com |
38 | Rita Marley | ritamarley@example.com |
39 | Peter Tosh | petertosh@example.com |
40 | Don James | john@example.com |
41 | Don James | john@example.com |
42 | John Deer | johnd@example.com |
43 | John Deere | john@deere.net |
44 | Don James | john@example.com |
45 | Donald Duck | dduckn@example.com |
46 | Daisy Duck | daisyduck@example.com |
47 | Julie Dooley | juliedooley@example.com |
48 | Tom Cat | tc@example.com |
49 | Woody Woodpecker | woody@example.com |
50 | Mighty Mouse | mighty@example.com |
51 | Bob Marley | bobmarley@example.com |
52 | Rita Marley | ritamarley@example.com |
53 | Peter Tosh | petertosh@example.com |
54 | John Deer | johnd@example.com |
55 | John Deere | john@deere.net |
56 | Don James | john@example.com |
57 | Don James | john@example.com |
58 | Tom Cat | tc@example.com |
59 | Woody Woodpecker | woody@example.com |
60 | Mighty Mouse | mighty@example.com |
61 | Donald Duck | dduckn@example.com |
62 | Daisy Duck | daisyduck@example.com |
63 | Julie Dooley | juliedooley@example.com |
64 | Bob Marley | bobmarley@example.com |
65 | Rita Marley | ritamarley@example.com |
66 | Peter Tosh | petertosh@example.com |
67 | John Deer | johnd@example.com |
68 | John Deere | john@deere.net |
69 | Bob Marley | bobmarley@example.com |
70 | Rita Marley | ritamarley@example.com |
71 | Peter Tosh | petertosh@example.com |
72 | Donald Duck | dduckn@example.com |
73 | Daisy Duck | daisyduck@example.com |
74 | Julie Dooley | juliedooley@example.com |
75 | John Deere | john@deere.net |
76 | Tom Cat | tc@example.com |
77 | Woody Woodpecker | woody@example.com |
78 | Mighty Mouse | mighty@example.com |
79 | Don James | john@example.com |
80 | Bob Marley | bobmarley@example.com |
81 | Rita Marley | ritamarley@example.com |
82 | Peter Tosh | petertosh@example.com |
83 | John Deer | johnd@example.com |
84 | Don James | john@example.com |
85 | John Deer | johnd@example.com |
86 | John Deere | john@deere.net |
87 | Don James | john@example.com |
88 | Don James | john@example.com |
89 | Tom Cat | tc@example.com |
90 | Woody Woodpecker | woody@example.com |
91 | Mighty Mouse | mighty@example.com |
92 | Donald Duck | dduckn@example.com |
93 | Daisy Duck | daisyduck@example.com |
94 | Julie Dooley | juliedooley@example.com |
95 | Bob Marley | bobmarley@example.com |
96 | Rita Marley | ritamarley@example.com |
97 | Peter Tosh | petertosh@example.com |
98 | Tom Cat | tc@example.com |
99 | Woody Woodpecker | woody@example.com |
100 | Mighty Mouse | mighty@example.com |
101 | Don James | john@example.com |
102 | Bob Marley | bobmarley@example.com |
103 | Rita Marley | ritamarley@example.com |
104 | Peter Tosh | petertosh@example.com |
105 | John Deer | johnd@example.com |
106 | John Deere | john@deere.net |
107 | Don James | john@example.com |
108 | Donald Duck | dduckn@example.com |
109 | Daisy Duck | daisyduck@example.com |
110 | Julie Dooley | juliedooley@example.com |
111 | Bob Marley | bobmarley@example.com |
112 | Rita Marley | ritamarley@example.com |
113 | Peter Tosh | petertosh@example.com |
114 | Tom Cat | tc@example.com |
115 | Woody Woodpecker | woody@example.com |
116 | Mighty Mouse | mighty@example.com |
117 | John Deere | john@deere.net |
118 | Don James | john@example.com |
119 | Donald Duck | dduckn@example.com |
120 | Daisy Duck | daisyduck@example.com |
121 | Julie Dooley | juliedooley@example.com |
122 | John Deer | johnd@example.com |
123 | Don James | john@example.com |
124 | Bob Marley | bobmarley@example.com |
125 | Rita Marley | ritamarley@example.com |
126 | Peter Tosh | petertosh@example.com |
127 | Don James | john@example.com |
128 | Donald Duck | dduckn@example.com |
129 | Daisy Duck | daisyduck@example.com |
130 | Julie Dooley | juliedooley@example.com |
131 | Don James | john@example.com |
132 | John Deere | john@deere.net |
133 | Tom Cat | tc@example.com |
134 | Woody Woodpecker | woody@example.com |
135 | Mighty Mouse | mighty@example.com |
136 | John Deer | johnd@example.com |
137 | Don James | john@example.com |
138 | Bob Marley | bobmarley@example.com |
139 | Rita Marley | ritamarley@example.com |
140 | Peter Tosh | petertosh@example.com |
141 | John Deere | john@deere.net |
142 | Tom Cat | tc@example.com |
143 | Woody Woodpecker | woody@example.com |
144 | Mighty Mouse | mighty@example.com |
145 | Donald Duck | dduckn@example.com |
146 | Daisy Duck | daisyduck@example.com |
147 | Julie Dooley | juliedooley@example.com |
148 | Don James | john@example.com |
149 | Don James | john@example.com |
150 | Bob Marley | bobmarley@example.com |
151 | Rita Marley | ritamarley@example.com |
152 | Peter Tosh | petertosh@example.com |
153 | John Deer | johnd@example.com |
154 | John Deere | john@deere.net |
155 | Tom Cat | tc@example.com |
156 | Woody Woodpecker | woody@example.com |
157 | Mighty Mouse | mighty@example.com |
158 | Donald Duck | dduckn@example.com |
159 | Daisy Duck | daisyduck@example.com |
160 | Julie Dooley | juliedooley@example.com |
161 | Don James | john@example.com |
162 | John Deer | johnd@example.com |
163 | John Deere | john@deere.net |
164 | Don James | john@example.com |
165 | Bob Marley | bobmarley@example.com |
166 | Rita Marley | ritamarley@example.com |
167 | Peter Tosh | petertosh@example.com |
168 | Tom Cat | tc@example.com |
169 | Woody Woodpecker | woody@example.com |
170 | Mighty Mouse | mighty@example.com |
171 | Don James | john@example.com |
172 | Donald Duck | dduckn@example.com |
173 | Daisy Duck | daisyduck@example.com |
174 | Julie Dooley | juliedooley@example.com |
175 | Tom Cat | tc@example.com |
176 | Woody Woodpecker | woody@example.com |
177 | Mighty Mouse | mighty@example.com |
178 | John Deer | johnd@example.com |
179 | John Deere | john@deere.net |
180 | Donald Duck | dduckn@example.com |
181 | Daisy Duck | daisyduck@example.com |
182 | Julie Dooley | juliedooley@example.com |
183 | Don James | john@example.com |
184 | Bob Marley | bobmarley@example.com |
185 | Rita Marley | ritamarley@example.com |
186 | Peter Tosh | petertosh@example.com |
187 | Don James | john@example.com |
188 | Donald Duck | dduckn@example.com |
189 | Daisy Duck | daisyduck@example.com |
190 | Julie Dooley | juliedooley@example.com |
191 | Don James | john@example.com |
192 | Tom Cat | tc@example.com |
193 | Woody Woodpecker | woody@example.com |
194 | Mighty Mouse | mighty@example.com |
Here is the code for accessing the database and display the information in a table.
<?php $servername = "localhost"; $username = "username"; $password = "password"; $dbname = "DBname"; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $sql = "SELECT id, firstname, lastname, email FROM MyGuests"; $result = $conn->query($sql); if ($result->num_rows > 0) { echo "<table><tr><th>ID</th><th>Name</th><th>Email</th> </tr>"; // output data of each row while($row = $result->fetch_assoc()) { echo "<tr style='background-color:yellow';><td>".$row["id"]."</td><td>".$row["firstname"]." ".$row["lastname"]."</td>".$row["email"]."</td></tr>"; } echo "</table>"; } else { echo "<p>0 results</p>"; } $conn->close(); ?>