$i = 0; while ($row = mysql_fetch_assoc($result)) { echo '"' . $row['tag'] . '"'; $i++; if ($i < $num_row) { echo ","; } } echo "]"; } } /** * Request Controller */ $request = strtolower($_GET["request"]); $q = strtolower($_GET["term"]); if (!$request || !$q) { getSearchMatches($q); } else { if ($request == "info") { getTagInfo($q); } else { if ($request == "matches") { getSearchMatches($q); } } } ?>
$whereAlive = "(bAlive = '1')"; } $whereAlive = "(1=1)"; if ($job == "buildDeviceList") { //$tags = (is_array($_REQUEST['tags'])) ? explode(",",$_REQUEST['tags']) : $_REQUEST['tags']; $tags = json_decode($_REQUEST['tags']); $sql = "SELECT tDeviceVPNName,nGroup,tLastAliveIP,bAlive,dLastAliveTime,RegionList.tRegionName as tRegionName, SubRegionList.tSubRegionName as tSubRegionName, tDeviceFirmware \n\tFROM DeviceList,RegionList,SubRegionList\n WHERE tDeviceVPNName IN ( select tDeviceVPNName from DeviceTags WHERE ("; //tTagIds REGEXP '(^|,)("; if (is_array($tags)) { foreach ($tags as $tagEntry => $params) { $tagInfo = getTagInfo($db_CS, $params->value); $result[] = array($tagInfo, fetchByTag2($db_CS, $params->value)); } } if (is_object($tags)) { $tagInfo = getTagInfo($db_CS, $tags->value); $result[] = array($tagInfo, fetchByTag2($db_CS, $tags->value)); } //echo json_encode($result, JSON_PRETTY_PRINT); //print_r ($result); $fetched['tagId'] = ""; $currentTag = ""; if (isset($result) && sizeof($result) > 0) { foreach ($result as $idx => $v) { //echo $v; if ($fetched['tagId'] == '') { $currentTag = $result[$idx][0]->id; } $fetched['tagId'] = $result[$idx][0]->id; $fetched['tagName'] = $result[$idx][0]->name; $fetched['deviceList'] = $result[$idx][1];