<? if($cmd=='newSave' ) $this->pageTitle = $form_name = _NEW_FORM_TITLE; else $this->pageTitle = $form_name = _EDIT_FORM_TITLE; if($p_strType == 'advert'){ $this->pageTitle = $form_name = _NEW_ADVERT_FORM_TITLE; } $DBbrand_opt[0] = _PLEASE_SELECT; if($arr['_form_title'] == 'Добавление нового автомобиля'){ $sql = "SELECT * FROM t_models WHERE parent_id = 0 AND status = 1 AND (vip = 2 OR vip = 3) ORDER BY name ASC"; }else{ $sql = "SELECT * FROM t_models WHERE parent_id = 0 AND status = 1 AND (vip = 1 OR vip = 3) ORDER BY name ASC"; } ?> 
  • that I didn't understand anything at all - Ale_x
  • Yes, everything is simple. See the code. May be described in too much detail ... Two drop-down lists. Sort by vip column. vip = 2 mark is reflected in the Add a new car section; vip = 1 brand is reflected in the VIP car sales section; vip = 0 marks are neither there nor there; vip = 3 mark both there and there. Question editing. Lists the list: $ sql = "SELECT * FROM t_models WHERE parent_id = 0 AND status = 1 AND (vip = 2 OR vip = 3) ORDER BY name ASC"; and you need to display else $ sql = "SELECT * FROM t_models WHERE parent_id = 0 AND status = 1 AND (vip = 1 OR vip = 3) ORDER BY name ASC"; - Greg888
  • one
    @ Serg107, Please arrange questions according to the rules of the community, otherwise they will be deleted. - Nicolas Chabanovsky

1 answer 1

$arr['_form_title'] - for editing what does it matter? - what data $arr['_form_title'] to the server?

try to rewrite it

 If ($cmd == 'newSave') { $strvip ="vip in (2,3)"; } else { $strvip ="vip in (1,3)"; } $sql="SELECT * FROM t_models WHERE parent_id = 0 AND status = 1 AND ".$strvip." ORDER BY name ASC"; 

Yes, and create the text of the query, add better in this place

 if($cmd == 'newSave') $this->pageTitle = $form_name = _NEW_FORM_TITLE; else $this->pageTitle = $form_name = _EDIT_FORM_TITLE; if($p_strType == 'advert') { $this->pageTitle = $form_name = _NEW_ADVERT_FORM_TITLE; } 
  • Initially there was a general list for everything. $ sql = "SELECT * FROM t_models WHERE parent_id = 0 AND status = 1 ORDER BY name ASC"; The task was divided into 2 lists - a short VIP and a long one all in a heap ... divided $ DBbrand_opt [0] = _PLEASE_SELECT; if ($ arr ['_ form_title'] == 'Adding a new car') $ sql = "SELECT * FROM t_models WHERE parent_id = 0 AND status = 1 AND (vip = 2 OR vip = 3) ORDER BY name ASC"; else $ sql = "SELECT * FROM t_models WHERE parent_id = 0 AND status = 1 AND (vip = 1 OR vip = 3) ORDER BY name ASC"; - Greg888
  • Well, where is the value of the $ arr ['_ form_title'] variable formed ?? - Ale_x
  • tin ...)))))) - Ale_x
  • if ($ arr ['_ form_title'] == 'Adding a new car' is not a good condition, they can stupidly change the name of the form, so I’d better go from If ($ cmd == 'newSave') - Ale_x
  • What helped, instead of _EDIT_FORM_TITLE stupidly put _NEW_FORM_TITLE (it turned out 2 _NEW_FORM_TITLE). It seems the lists are correct, but instead of editing, add a new car ... if ($ cmd == 'newSave') $ this-> pageTitle = $ form_name = _NEW_FORM_TITLE; else $ this-> pageTitle = $ form_name = _NEW_FORM_TITLE; if ($ p_strType == 'advert') {$ this-> pageTitle = $ form_name = _NEW_ADVERT_FORM_TITLE; } - Greg888