質問編集履歴

2

修正

2019/12/10 12:31

投稿

watta_00
watta_00

スコア16

test CHANGED
File without changes
test CHANGED
@@ -18,7 +18,7 @@
18
18
 
19
19
 
20
20
 
21
- このindexという部分をphpで検索して、ヒットしたらif文(何らかの処理)を実行してみたいです。
21
+ このindexという部分をphpで検索して、ヒットしたらif文(print関数でhtmlにhtml文を記載)を実行してみたいです。
22
22
 
23
23
  ```php
24
24
 

1

ソース追加

2019/12/10 12:31

投稿

watta_00
watta_00

スコア16

test CHANGED
File without changes
test CHANGED
@@ -20,6 +20,24 @@
20
20
 
21
21
  このindexという部分をphpで検索して、ヒットしたらif文(何らかの処理)を実行してみたいです。
22
22
 
23
+ ```php
24
+
25
+ function test(){
26
+
23
- strposどの関数を使用てみましたが、どうもうまくいきません
27
+ $hoge=db();//データベース接続は問題なし。
28
+
29
+ $sql="SELECT * FROM mondai WHERE id=$id";
30
+
31
+ $stmt= $hoge->prepare($sql);
32
+
33
+ $stmt->execute();
34
+
35
+ $result = $stmt->fetch(PDO::FETCH_ASSOC);
36
+
37
+ echo nl2br(htmlspecialchars($result["source2"]));
38
+
39
+ ```
40
+
41
+
24
42
 
25
43
  力を貸してください。