Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 49c23c7

Browse files
Added colours table
1 parent 1250405 commit 49c23c7

File tree

3 files changed

+97
-6
lines changed

3 files changed

+97
-6
lines changed

‎db/colours.sql

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
-- phpMyAdmin SQL Dump
2+
-- version 5.2.2
3+
-- https://www.phpmyadmin.net/
4+
--
5+
-- Host: db:3306
6+
-- Generation Time: Jan 31, 2025 at 03:45 PM
7+
-- Server version: 9.2.0
8+
-- PHP Version: 8.2.27
9+
10+
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
11+
START TRANSACTION;
12+
SET time_zone = "+00:00";
13+
14+
15+
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
16+
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
17+
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
18+
/*!40101 SET NAMES utf8mb4 */;
19+
20+
--
21+
-- Database: `demo`
22+
--
23+
24+
-- --------------------------------------------------------
25+
26+
--
27+
-- Table structure for table `colours`
28+
--
29+
30+
CREATE TABLE `colours` (
31+
`id` int NOT NULL,
32+
`name` varchar(255) NOT NULL,
33+
`rgb` varchar(255) NOT NULL
34+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
35+
36+
--
37+
-- Dumping data for table `colours`
38+
--
39+
40+
INSERT INTO `colours` (`id`, `name`, `rgb`) VALUES
41+
(1, 'Red', '#ff0000'),
42+
(2, 'Blue', '#0000ff'),
43+
(3, 'Green', '#00ff00');
44+
45+
--
46+
-- Indexes for dumped tables
47+
--
48+
49+
--
50+
-- Indexes for table `colours`
51+
--
52+
ALTER TABLE `colours`
53+
ADD PRIMARY KEY (`id`);
54+
55+
--
56+
-- AUTO_INCREMENT for dumped tables
57+
--
58+
59+
--
60+
-- AUTO_INCREMENT for table `colours`
61+
--
62+
ALTER TABLE `colours`
63+
MODIFY `id` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
64+
COMMIT;
65+
66+
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
67+
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
68+
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

‎docker-compose.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
version: "3"
21
services:
32
www:
43
depends_on:
@@ -9,13 +8,16 @@ services:
98
- 443:443
109
volumes:
1110
- ./www:/var/www/html
11+
command: "/bin/sh -c 'docker-php-ext-install mysqli && apache2-foreground'"
1212
db:
1313
image: mysql:latest
1414
environment:
1515
MYSQL_DATABASE: demo
1616
MYSQL_USER: demo
1717
MYSQL_PASSWORD: password
1818
MYSQL_ALLOW_EMPTY_PASSWORD: 1
19+
volumes:
20+
- ./db:/docker-entrypoint-initdb.d
1921
phpmyadmin:
2022
depends_on:
2123
- db
@@ -24,8 +26,4 @@ services:
2426
- 81:80
2527
environment:
2628
PMA_HOST: db
27-
PMA_PORT: 3306
28-
29-
# localhost:81
30-
# Log in using demo and password
31-
29+
PMA_PORT: 3306

‎www/index.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,31 @@
1010
<h1>Home Page</h1>
1111

1212
<?php echo "<p>Hello Word!</p>"; ?>
13+
14+
<?php
15+
16+
$connect = mysqli_connect(
17+
'db',
18+
'demo',
19+
'password',
20+
'demo'
21+
);
22+
23+
$query = 'SELECT *
24+
FROM colours
25+
ORDER BY name';
26+
$result = mysqli_query($connect, $query);
27+
28+
while($record = mysqli_fetch_assoc($result))
29+
{
30+
31+
echo '<h2>'.$record['name'].'</h2>
32+
<div style="width: 200px; height: 200px; background-color: '.$record['rgb'].';"></div>
33+
<hr>';
34+
35+
}
36+
37+
?>
1338

1439
</body>
1540
</html>

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /