質問編集履歴

2

コードの詳細追記

2019/10/04 05:44

投稿

narugaro
narugaro

スコア5

test CHANGED
File without changes
test CHANGED
@@ -16,13 +16,25 @@
16
16
 
17
17
  post_id meta_key meta_value
18
18
 
19
+ 1 イベント名 役員会議
20
+
21
+ 1 名前 山田太郎
22
+
19
23
  1 件名1 参加
20
24
 
21
25
  1 件名2 不参加
22
26
 
27
+ 2 イベント名 役員会議
28
+
29
+ 2 名前 田中花子
30
+
23
31
  2 件名1 参加
24
32
 
25
33
  2 件名2 参加
34
+
35
+ 3 イベント名 合同イベント
36
+
37
+ 3 名前 鈴木一郎
26
38
 
27
39
  3 件名1 不参加
28
40
 
@@ -40,37 +52,55 @@
40
52
 
41
53
  ```php
42
54
 
43
- while ($row = mysql_fetch_assoc($result1)) {
55
+ $title = '役員会議';
44
56
 
45
- $post_id = $row['post_id'];
57
+ $event_name = "イベント名";
46
58
 
47
- $label1 = "件名1";
59
+ $sql = "SELECT *
48
60
 
61
+ FROM at_postmeta
62
+
63
+ WHERE meta_key = '$event_name'
64
+
65
+ AND meta_value = '$title'";
66
+
49
- $sanka = "参加";
67
+ $result1 = mysql_query($sql);
50
68
 
51
69
 
52
70
 
53
- $sql = "SELECT COUNT(meta_value = '$sanka' OR null) AS cnt
71
+ while ($row = mysql_fetch_assoc($result1)) {
54
72
 
55
- FROM at_postmeta
73
+ $post_id = $row['post_id'];
56
74
 
57
- WHERE post_id = '$post_id'
75
+ $label1 = "件名1";
58
76
 
59
- AND meta_key = '$label1'
60
-
61
- ";
62
-
63
- $result = mysql_query($sql);
77
+ $sanka = "参加";
64
78
 
65
79
 
66
80
 
67
- while ($row = mysql_fetch_assoc($result)){
81
+ $sql = "SELECT COUNT(meta_value = '$sanka' OR null) AS cnt
68
82
 
83
+ FROM at_postmeta
84
+
85
+ WHERE post_id = '$post_id'
86
+
87
+ AND meta_key = '$label1'
88
+
89
+ ";
90
+
91
+ $result = mysql_query($sql);
92
+
93
+
94
+
95
+ while ($row = mysql_fetch_assoc($result)){
96
+
69
- $sum += $row['cnt'];
97
+ $sum += $row['cnt'];
98
+
99
+ }
100
+
101
+ echo $sum;
70
102
 
71
103
  }
72
-
73
- echo $sum;
74
104
 
75
105
  ```
76
106
 

1

誤字修正

2019/10/04 05:43

投稿

narugaro
narugaro

スコア5

test CHANGED
File without changes
test CHANGED
@@ -39,6 +39,8 @@
39
39
 
40
40
 
41
41
  ```php
42
+
43
+ while ($row = mysql_fetch_assoc($result1)) {
42
44
 
43
45
  $post_id = $row['post_id'];
44
46