Basically i want to select rows base of specific row values specific row id how to get $query_post1
this try not get error
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'AND n.content_type = 'Post' GROUP BY n.recipe_id ORDER BY n.recipe_i...' at line 38106
echo
SELECT DISTINCT n.recipe_id, n.recipe_title, n.cat_id, n.recipe_time,n.price,n.discountprice, n.recipe_image, n.recipe_description, n.video_url, n.video_id, n.content_type, n.featured, n.tags, n.total_views,COUNT(DISTINCT r.comment_id) as comments_count, c.category_name FROM tbl_recipes1 n LEFT JOIN tbl_category1 c ON n.cat_id = c.cid LEFT JOIN tbl_comments1 r ON n.recipe_id = r.recipe_id WHERE c.cid = AND n.content_type = 'Post' GROUP BY n.recipe_id ORDER BY n.recipe_id DESC LIMIT 10 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'AND n.content_type = 'Post' GROUP BY n.recipe_id ORDER BY n.recipe_i...' at line 38109
public function getHome1() { include "../includes/config.php"; $setting_qry = "SELECT * FROM tbl_settings where id = '1'"; $setting_result = mysqli_query($connect, $setting_qry); $settings_row = mysqli_fetch_assoc($setting_result); $api_key = $settings_row['api_key']; $setting_qry1 = "SELECT * FROM tbl_category1 where ROWNUM = '1'"; $setting_result1 = mysqli_query($connect, $setting_qry1); $settings_row1 = mysqli_fetch_assoc($setting_result1); $api_key1 = $settings_row['cid']; $comment_approval = $settings_row['comment_approval']; if (isset($_GET['api_key'])) { $access_key_received = $_GET['api_key']; if ($access_key_received == $api_key) { $limit = 10; if($this->get_request_method() != "GET") $this->response('',406); $query_category = "SELECT DISTINCT c.cid, c.category_name, c.category_image, COUNT(DISTINCT r.recipe_id) as recipes_count FROM tbl_category1 c LEFT JOIN tbl_recipes1 r ON c.cid = r.cat_id GROUP BY c.cid ORDER BY c.cid DESC LIMIT $limit"; $query_featured = "SELECT DISTINCT n.recipe_id, n.recipe_title, n.cat_id, n.recipe_time,n.price,n.discountprice, n.recipe_image, n.recipe_description, n.video_url, n.video_id, n.content_type, n.featured, n.tags, n.total_views, c.category_name, n.last_update FROM tbl_recipes1 n LEFT JOIN tbl_category1 c ON n.cat_id = c.cid WHERE n.featured = '1' GROUP BY n.recipe_id ORDER BY n.last_update DESC"; $query_recent = "SELECT DISTINCT n.recipe_id, n.recipe_title, n.cat_id, n.recipe_time,n.price,n.discountprice, n.recipe_image, n.recipe_description, n.video_url, n.video_id, n.content_type, n.featured, n.tags, n.total_views,COUNT(DISTINCT r.comment_id) as comments_count, c.category_name FROM tbl_recipes1 n LEFT JOIN tbl_category1 c ON n.cat_id = c.cid LEFT JOIN tbl_comments1 r ON n.recipe_id = r.recipe_id WHERE n.content_type = 'Post' GROUP BY n.recipe_id ORDER BY n.recipe_id DESC LIMIT $limit "; $query_post1 = "SELECT DISTINCT n.recipe_id, n.recipe_title, n.cat_id, n.recipe_time,n.price,n.discountprice, n.recipe_image, n.recipe_description, n.video_url, n.video_id, n.content_type, n.featured, n.tags, n.total_views,COUNT(DISTINCT r.comment_id) as comments_count, c.category_name FROM tbl_recipes1 n LEFT JOIN tbl_category1 c ON n.cat_id = c.cid LEFT JOIN tbl_comments1 r ON n.recipe_id = r.recipe_id WHERE c.cid = $api_key1 AND n.content_type = 'Post' GROUP BY n.recipe_id ORDER BY n.recipe_id DESC LIMIT $limit "; $query_videos = "SELECT DISTINCT n.recipe_id, n.recipe_title, n.cat_id, n.recipe_time,n.price,n.discountprice, n.recipe_image, n.recipe_description, n.video_url, n.video_id, n.content_type, n.featured, n.tags, n.total_views, c.category_name FROM tbl_recipes1 n LEFT JOIN tbl_category1 c ON n.cat_id = c.cid WHERE n.content_type != 'Post' GROUP BY n.recipe_id ORDER BY n.recipe_id DESC LIMIT $limit"; $category = $this->get_list_result($query_category); $featured = $this->get_list_result($query_featured); $videos = $this->get_list_result($query_videos); $recent = $this->get_list_result($query_recent); $post1= $this->get_list_result($query_post1); $respon = array('status' => 'ok', 'featured' => $featured, 'category' => $category, 'recent' => $recent,'post1' => $post1, 'videos' => $videos); $this->response($this->json($respon), 200); } else { $respon = array( 'status' => 'failed', 'message' => 'Oops, API Key is Incorrect!'); $this->response($this->json($respon), 404); } } else { $respon = array( 'status' => 'failed', 'message' => 'Forbidden, API Key is Required!'); $this->response($this->json($respon), 404); } }