質問編集履歴
3
前の例題分を入力しました
title
CHANGED
File without changes
|
body
CHANGED
@@ -15,22 +15,76 @@
|
|
15
15
|
|
16
16
|
```php
|
17
17
|
ソースコード
|
18
|
-
```
|
19
|
-
```html<!DOCTYPE html>``````html
|
20
|
-
コード
|
21
18
|
|
19
|
+
//前の例題分 表作成 エラーは表示されていません
|
20
|
+
<!DOCTYPE html>
|
21
|
+
<html>
|
22
|
+
<head>
|
23
|
+
<meta charset="UTF-8"/>
|
24
|
+
<title>11-1</title>
|
25
|
+
</head>
|
26
|
+
<body>
|
27
|
+
<?php
|
28
|
+
$dbname= "sqlite:pdd.db";
|
29
|
+
$username= "";
|
30
|
+
$psword= "";
|
31
|
+
|
32
|
+
$db= new PDO($dbname,$username,$psword);
|
33
|
+
$db->exec("DROP TABLE IF EXISTS product");
|
34
|
+
$db->exec("CREATE TABLE product(id INTEGER PRIMARY KEY,name STRING,price INTEGER)");
|
35
|
+
|
36
|
+
$qry=array(
|
37
|
+
"INSERT INTO product (name, price) VALUES('鉛筆', 80)",
|
38
|
+
"INSERT INTO product (name, price) VALUES('消しゴム', 50)",
|
39
|
+
"INSERT INTO product (name, price) VALUES('定規', 200)",
|
40
|
+
"INSERT INTO product (name, price) VALUES('コンパス', 300)",
|
41
|
+
"INSERT INTO product (name, price) VALUES('ボールペン', 100)"
|
42
|
+
);
|
43
|
+
foreach($qry as $value){
|
44
|
+
$db->exec($value);
|
45
|
+
}$qry="SELECT * FROM product";
|
46
|
+
$data= $db->query($qry);
|
47
|
+
?>
|
48
|
+
|
49
|
+
<table border="2">
|
50
|
+
<tr bgcolor="#AAAAAA">
|
51
|
+
<th>番号</th>
|
52
|
+
<th>商品名</th>
|
53
|
+
<th>単価</th>
|
54
|
+
</tr>
|
55
|
+
|
56
|
+
<?php
|
57
|
+
while($value = $data->fetch()){
|
58
|
+
$id = $value["id"];
|
59
|
+
$name = $value["name"];
|
60
|
+
$price = $value["price"];
|
61
|
+
print "<tr><td>{$id}</td><td>{$name}</td><td>{$price}</td></tr>\n";
|
62
|
+
}
|
63
|
+
$db = null;
|
64
|
+
?>
|
65
|
+
|
66
|
+
</table>
|
67
|
+
</body>
|
68
|
+
</html>
|
22
69
|
```
|
23
|
-
<html>```html
|
24
|
-
コード
|
25
|
-
```
|
26
70
|
|
27
71
|
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
```html<!DOCTYPE html>````html
|
78
|
+
//これから下がエラーがでている分
|
79
|
+
<html>`
|
28
80
|
<head>
|
29
81
|
<meta charset="UTF-8"/>
|
30
82
|
<title>11-6</title>
|
31
83
|
</head>
|
32
84
|
<body>
|
33
85
|
```
|
86
|
+
|
87
|
+
```
|
34
88
|
```php
|
35
89
|
<?php
|
36
90
|
|
2
コードのマークを修正しました
title
CHANGED
File without changes
|
body
CHANGED
@@ -15,9 +15,16 @@
|
|
15
15
|
|
16
16
|
```php
|
17
17
|
ソースコード
|
18
|
-
```
|
18
|
+
```
|
19
|
-
<!DOCTYPE html>
|
19
|
+
```html<!DOCTYPE html>``````html
|
20
|
+
コード
|
21
|
+
|
22
|
+
```
|
20
|
-
<html>
|
23
|
+
<html>```html
|
24
|
+
コード
|
25
|
+
```
|
26
|
+
|
27
|
+
|
21
28
|
<head>
|
22
29
|
<meta charset="UTF-8"/>
|
23
30
|
<title>11-6</title>
|
@@ -46,8 +53,8 @@
|
|
46
53
|
|
47
54
|
?>
|
48
55
|
```
|
56
|
+
```html
|
49
57
|
|
50
|
-
```css
|
51
58
|
<table border="2">
|
52
59
|
<tr bgcolor="#AAAAAA">
|
53
60
|
<th>番号</th>
|
1
ソースコードにマークダウンのcode機能を利用 表示したいものを試したいものに移動
title
CHANGED
File without changes
|
body
CHANGED
@@ -15,7 +15,7 @@
|
|
15
15
|
|
16
16
|
```php
|
17
17
|
ソースコード
|
18
|
-
```
|
18
|
+
```HTML
|
19
19
|
<!DOCTYPE html>
|
20
20
|
<html>
|
21
21
|
<head>
|
@@ -23,6 +23,8 @@
|
|
23
23
|
<title>11-6</title>
|
24
24
|
</head>
|
25
25
|
<body>
|
26
|
+
```
|
27
|
+
```php
|
26
28
|
<?php
|
27
29
|
|
28
30
|
$dbname = "sqlite:pdb.db";
|
@@ -43,14 +45,18 @@
|
|
43
45
|
$stmt->execute();
|
44
46
|
|
45
47
|
?>
|
48
|
+
```
|
46
49
|
|
50
|
+
```css
|
47
|
-
|
51
|
+
<table border="2">
|
48
52
|
<tr bgcolor="#AAAAAA">
|
49
53
|
<th>番号</th>
|
50
54
|
<th>商品名</th>
|
51
55
|
<th>単価</th>
|
52
56
|
</tr>
|
57
|
+
```
|
53
58
|
|
59
|
+
```php
|
54
60
|
<?php
|
55
61
|
error_reporting(E_ALL);
|
56
62
|
ini_set('display_errors', '1');
|
@@ -68,6 +74,8 @@
|
|
68
74
|
|
69
75
|
?>
|
70
76
|
|
77
|
+
```
|
78
|
+
```html
|
71
79
|
</table>
|
72
80
|
<form action="http://localhost/YPHPSample/11/Sample11-6.php" method="post">
|
73
81
|
<input type="text" name="word"/>
|
@@ -75,10 +83,12 @@
|
|
75
83
|
</form>
|
76
84
|
</body>
|
77
85
|
</html>
|
86
|
+
```
|
78
87
|
|
79
88
|
|
89
|
+
|
90
|
+
## 試したこと
|
80
91
|
表示したいもの
|
81
|
-
|
82
92
|
番号 商品名 単価
|
83
93
|
1 鉛筆 80
|
84
94
|
2 消しゴム 50
|
@@ -86,8 +96,7 @@
|
|
86
96
|
4 コンパス 300
|
87
97
|
5 ボールペン 100
|
88
98
|
× 検索
|
89
|
-
|
99
|
+
試したこと
|
90
|
-
|
91
100
|
いろいろ検索しました
|
92
101
|
ここをみろとかいてありましたが何をいっているの内容自体がさっぱりわかりません
|
93
102
|
すみませんが教えてください
|