Cheetah
ads_get_list.php
Go to the documentation of this file.
1 <?php
2 
8 require_once('../../../inc/header.inc.php');
9 require_once( CH_DIRECTORY_PATH_INC . "db.inc.php" );
10 
11 $sSQL = '';
12 $iCategID = (int)ch_get('cat_id');
13 
14 $aResult = array();
15 
16 switch (ch_get('action')) {
17  case 'get_subcat_info':
18  default:
19  if ($iCategID>0) {
20  $sCustName1 = $sCustName2 = $sUnit = $sUnit2 = '';
21  $sSQL = "
22  SELECT `ch_ads_category_subs`.`ID` , `ch_ads_category_subs`.`NameSub` AS `Name`, `CustomFieldName1`, `CustomFieldName2`, `Unit1`, `Unit2`
23  FROM `ch_ads_category_subs`
24  INNER JOIN `ch_ads_category` ON (`ch_ads_category`.`ID`=`ch_ads_category_subs`.`IDClassified`)
25  WHERE `ch_ads_category_subs`.`IDClassified` = '{$iCategID}'
26  ORDER BY `Name` ASC
27  ";
28 
29  $aSubCats = array();
30  $vData = db_res($sSQL);
31  while ($aUnit = $vData->fetch()) {
32  if ($sCustName1 == '') {
33  $sCustName1 = htmlspecialchars($aUnit['CustomFieldName1']);
34  }
35  if ($sCustName2 == '') {
36  $sCustName2 = htmlspecialchars($aUnit['CustomFieldName2']);
37  }
38  if ($sUnit == '') {
39  $sUnit = htmlspecialchars($aUnit['Unit1']);
40  }
41  if ($sUnit2 == '') {
42  $sUnit2 = htmlspecialchars($aUnit['Unit2']);
43  }
44 
45  $iSubCatID = (int)$aUnit['ID'];
46  $iSubCatName = ($aUnit['Name']);
47  $aSubCats[] = array('id' => $iSubCatID, 'value' => $iSubCatName);
48  }
49 
50  $aResult['CustomFieldName1'] = $sCustName1;
51  $aResult['CustomFieldName2'] = $sCustName2;
52  $aResult['Unit'] = $sUnit;
53  $aResult['Unit2'] = $sUnit2;
54  $aResult['SubCats'] = $aSubCats;
55 
56  echo json_encode($aResult);
57  }
58  break;
59 }
$aUnit
$aUnit
Definition: short_profile_info.php:31
ch_get
ch_get($sName)
Definition: utils.inc.php:1664
$sSQL
$sSQL
Definition: ads_get_list.php:11
php
$iCategID
$iCategID
Definition: ads_get_list.php:12
$aResult
$aResult
Definition: ads_get_list.php:14
db_res
db_res($query, $bindings=[])
Definition: db.inc.php:39