Post

3 followers Follow
0
Avatar

use limit and filter in PHP

I wrote this piece of code in PHP.

$result = mysqli_query($connection, "SELECT * FROM app WHERE" . $_REQUEST['filter'] . " ORDER BY " . $_REQUEST['sort']);

$output = array();
while($row = mysqli_fetch_array($result)) {
$record = array();
$record['app_id'] = $row['app_id'];
$record['app_name'] = $row['app_name'];

$output[] = $record;

}

I want to use LIMIT as well.

When i use LIMIT at ..... " ORDER BY " . $_REQUEST['sort'] . "LIMIT 3"); it gives me this error: filter =1=1 sort = 1=1

Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in ....service.php on line 80

How can I do that? Thank you in advance

sajad mirzayi

Please sign in to leave a comment.

2 comments