質問編集履歴
5
改善
title
CHANGED
File without changes
|
body
CHANGED
File without changes
|
4
改善
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
ORDER BY
|
1
|
+
ORDER BY ~ DESCってどういう意味ですか
|
2
2
|
|
3
3
|
追記
|
4
4
|
テーブル:「name(int)」「comment(varchar)」「time(timestamp)」
|
3
改善
title
CHANGED
File without changes
|
body
CHANGED
@@ -17,7 +17,7 @@
|
|
17
17
|
|
18
18
|
$query = "SELECT * FROM XXX";
|
19
19
|
|
20
|
-
$result = $mysqli->query("SELECT * FROM XXX ORDER BY
|
20
|
+
$result = $mysqli->query("SELECT * FROM XXX ORDER BY time DESC");
|
21
21
|
if($result){
|
22
22
|
while($row = $result->fetch_object()){
|
23
23
|
$name = htmlspecialchars($row->name);
|
2
改善
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
|
1
|
+
order byに関して分からないことがあります
|
body
CHANGED
@@ -1,4 +1,9 @@
|
|
1
1
|
ORDER BY created DESCってどういう意味ですか
|
2
|
+
|
3
|
+
追記
|
4
|
+
テーブル:「name(int)」「comment(varchar)」「time(timestamp)」
|
5
|
+
[リンク内容](https://team-lab.github.io/skillup/1/9.html)
|
6
|
+
|
2
7
|
```PHP
|
3
8
|
$mysqli = new mysqli($host, $user, $password, $dbname);
|
4
9
|
if ($mysqli->connect_error){
|
1
改善
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,1 +1,25 @@
|
|
1
|
-
ORDER BY created DESCってどういう意味ですか
|
1
|
+
ORDER BY created DESCってどういう意味ですか
|
2
|
+
```PHP
|
3
|
+
$mysqli = new mysqli($host, $user, $password, $dbname);
|
4
|
+
if ($mysqli->connect_error){
|
5
|
+
print("接続失敗:" . $mysqli->connect_error);
|
6
|
+
exit();
|
7
|
+
}
|
8
|
+
|
9
|
+
$stmt = $mysqli->prepare("INSERT INTO XXX (name, comment) VALUES (?, ?)");
|
10
|
+
$stmt->bind_param('ss', $_POST["name"], $_POST["comment"]);
|
11
|
+
$stmt->execute();
|
12
|
+
|
13
|
+
$query = "SELECT * FROM XXX";
|
14
|
+
|
15
|
+
$result = $mysqli->query("SELECT * FROM XXX ORDER BY created DESC");
|
16
|
+
if($result){
|
17
|
+
while($row = $result->fetch_object()){
|
18
|
+
$name = htmlspecialchars($row->name);
|
19
|
+
$comment = htmlspecialchars($row->comment);
|
20
|
+
}
|
21
|
+
}
|
22
|
+
|
23
|
+
$mysqli->close();
|
24
|
+
|
25
|
+
```
|