<?php


if(isset($type) && $type=="cart"){
//select all yes ref yes sec_id	
$query="SELECT id from $table WHERE $where_col ='$where_value' AND $status_col='$status_value' AND $ref_col='$ref_value'";
}

if(isset($type) && $type=="cart_fetch"){
//select all yes ref yes sec_id	
$query="SELECT ".implode(",", $fields_array)." from $table WHERE $where_col ='$where_value' AND $status_col='$status_value' AND $ref_col='$ref_value' ORDER BY id DESC";
}

if(isset($type) && $type=="element_fetch"){
//select all yes ref yes sec_id	
$query="SELECT ".implode(",", $fields_array)." from $table WHERE $status_col='$status_value' AND $ref_col IN($ref_value) ORDER BY id DESC";
}

if(isset($type) && $type=="art_fetch"){
//select all yes ref yes sec_id	
$query="SELECT ".implode(",", $fields_array)." from $table WHERE $status_col='$status_value' AND $ref_col IN($ref_value) ORDER BY RAND() LIMIT 1";
}

if(isset($type) && $type=="art_fetch1"){
//select all yes ref yes sec_id	
$query="SELECT ".implode(",", $fields_array)." from $table WHERE $status_col='$status_value' AND $ref_col IN($ref_value)";
}

if(isset($type) && $type=="page_fetch"){
//select all yes ref yes sec_id	
$query="SELECT ".implode(",", $fields_array)." from $table WHERE $status_col='$status_value' AND $ref_col IN($ref_value) AND $where_col ='$where_value'";
}

if(isset($type) && $type=="search_words"){
$fields1=implode(",", $fields_array);
$deal_title1=title;
$company_name1=terms;
$ref_type="product_entry";
//select all yes array by search terms
$query="SELECT $fields1 from $table WHERE ($company_name1 LIKE '%".$keywords."%' OR $deal_title1 LIKE '%".$keywords."%') AND $status_col='$status_value' AND $ref_col IN($ref_value) LIMIT $select_all_pagination_start,$select_all_pagination_limit";
}


if(isset($type) && $type=="cat_name"){
//select all yes ref yes sec_id	
$query="SELECT ".implode(",", $fields_array)." from $table WHERE $where_col ='$where_value' AND $status_col='$status_value' AND $ref_col IN($ref_value) ORDER BY id DESC LIMIT 1";
}

if(isset($type) && $type=="add_cart_check"){
//select all yes ref yes sec_id	
$query="SELECT ".implode(",", $fields_array)." from $table WHERE $where_col ='$where_value' AND $where_col2 ='$where_value2' AND $status_col='$status_value' AND $ref_col IN($ref_value) ORDER BY id DESC";
}


//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
if(isset($type) && $type=="select all no ref"){
$query="SELECT * from $table WHERE $id_col='$id' AND $status_col='$status_value'";
}

if(isset($type) && $type=="3"){
//select all yes ref	
$query="SELECT * from $table WHERE $ref_col='$ref_value' AND $status_col='$status_value'";
}


if(isset($type) && $type=="6"){
//select all yes ref yes sec_id	
$query="SELECT * from $table WHERE $ref_col='$ref_value' AND $sec_id_col='$sec_id' AND $status_col='$status_value'";
}




/////////////////////////////
/////////////////////////////
/////////////////////////////
/////////////////////////////
/////////////////////////////
if(isset($type) && $type=="7"){
//select all yes ref yes sec_id	
$query="SELECT * from $table WHERE $where_col IN($where_value) AND $status_col='$status_value' AND $ref_col='$ref_value' 
ORDER BY $order_col $order LIMIT $select_all_pagination_start, $select_all_pagination_limit";

}
//////////////////////////////////////
//////////////////////////////////////
//////////////////////////////////////
//////////////////////////////////////
//////////////////////////////////////
//////////////////////////////////////






if(isset($type) && $type=="8"){
//select all yes ref yes sec_id	
$query="SELECT $where_col from $table WHERE $where_col IN($where_value) AND $status_col='$status_value' AND $ref_col='$ref_value' 
ORDER BY $order_col $order";
}


if(isset($type) && $type=="select all yes array"){
$query="SELECT ".implode(",", $fields_array)." from $table WHERE $id_col='$id' AND $status_col='$status_value' AND $ref_col IN($ref_value)";
}

if(isset($type) && $type=="select all yes array site"){
$query="SELECT ".implode(",", $fields_array)." from $table WHERE $status_col='$status_value' AND $ref_col IN($ref_value) ORDER BY RAND()";
}

if(isset($type) && $type=="select all yes array recent"){
$query="SELECT ".implode(",", $fields_array)." from $table WHERE $status_col='$status_value' AND $ref_col IN($ref_value) ORDER BY RAND() LIMIT 8 ";
}

if(isset($type) && $type=="select all yes array site limit"){
$query="SELECT ".implode(",", $fields_array)." from $table WHERE $status_col='$status_value' AND $ref_col IN($ref_value) ORDER BY RAND() LIMIT $limit";
}

if(isset($type) && $type=="select category pagination site"){
$query="SELECT ".implode(",", $fields_array)." from $table WHERE $where_col IN($where_value) AND $status_col='$status_value' AND $ref_col IN($ref_value) ORDER BY $order_col $order LIMIT $select_all_pagination_start, $select_all_pagination_limit";
}

if(isset($type) && $type=="select all yes array2"){
$query="SELECT ".implode(",", $fields_array)." from $table WHERE $status_col='$status_value' AND $ref_col IN($ref_value) ORDER BY RAND() LIMIT 5";
}
if(isset($type) && $type=="select all yes array3"){
$query="SELECT ".implode(",", $fields_array)." from $table WHERE $status_col='$status_value' AND $ref_col IN($ref_value) LIMIT 1";
}
if(isset($type) && $type=="1"){
//select all yes array order
$query="SELECT ".implode(",", $fields_array)." from $table WHERE $status_col='$status_value'
 AND $ref_col IN($ref_value) ORDER BY $order_col $order";
 }
 
if(isset($type) && $type=="1b"){
//select all yes array by legend order
$query="SELECT ".implode(",", $fields_array)." from $table WHERE $status_col='$status_value'
 AND $where_col='$where_value' AND $ref_col IN($ref_value) ORDER BY $order_col $order";
  
}

 if(isset($type) && $type=="1c"){
//select all yes array by legend order
$query="SELECT ".implode(",", $fields_array)." from $table WHERE $status_col='$status_value'
 AND $where_col='$where_value' AND $ref_col IN($ref_value) ORDER BY col20 DESC , $order_col $order  LIMIT $limit";
 }

 if(isset($type) && $type=="1c_adv"){
//select all yes array by legend order
$query="SELECT ".implode(",", $fields_array)." from $table WHERE $status_col='$status_value'
 AND $where_col='$where_value' AND $ref_col ='$ref_value' ORDER BY $order_col DESC , $order_col $order  LIMIT $limit";
 }

 
 if(isset($type) && $type=="dropdown_select"){
//select all yes array by legend order
$query="SELECT ".implode(",", $fields_array)." from $table WHERE $status_col='$status_value'
 AND $ref_col='$ref_value' LIMIT $limit";

 } 
 
if(isset($type) && $type=="select_by_limit"){
//select all yes array by legend order
$query="SELECT ".implode(",", $fields_array)." from $table WHERE $status_col='$status_value'
 AND $ref_col IN($ref_value) LIMIT $limit";
 }

 if(isset($type) && $type=="1d"){
//select all yes array by legend order
$query="SELECT ".implode(",", $fields_array)." from $table WHERE $status_col='$status_value'
 AND $where_col='$where_value' AND $ref_col IN($ref_value) ORDER BY $order_col $order 
 LIMIT $select_all_pagination_start, $select_all_pagination_limit";
 
     
 }

















?>