回答編集履歴
1
sqlの追加
answer
CHANGED
|
@@ -105,4 +105,26 @@
|
|
|
105
105
|
<? require( 'footer.php' ) ?>
|
|
106
106
|
```
|
|
107
107
|
|
|
108
|
-
多分こんな感じ。
|
|
108
|
+
多分こんな感じ。
|
|
109
|
+
|
|
110
|
+
```lang-php
|
|
111
|
+
//条件に引っかかった値を全カラム取得
|
|
112
|
+
$sql = "SELECT "
|
|
113
|
+
. "* "
|
|
114
|
+
. "FROM "
|
|
115
|
+
//item tableにauthor tableをauthor_idで結合
|
|
116
|
+
. "item "
|
|
117
|
+
. "LEFT JOIN "
|
|
118
|
+
. "author "
|
|
119
|
+
. "ON "
|
|
120
|
+
. "item.author_id = author.author_id "
|
|
121
|
+
//検索用のWhereで絞り込み
|
|
122
|
+
. "where "
|
|
123
|
+
. $where
|
|
124
|
+
//並び順の設定
|
|
125
|
+
. "order by "
|
|
126
|
+
. mysql_real_escape_string( $_GET['sort'] )
|
|
127
|
+
//page件目からrows件のデータを取得
|
|
128
|
+
//TODO:ここインジェクションの脆弱性があるため、このままでは必ず実装しないこと
|
|
129
|
+
. " LIMIT ${_GET['page']}, ${_GET['rows']}";
|
|
130
|
+
```
|