/** * Select priority control * * Params: * * - Commong SELECT attributes * - Value - Selected priority * * @param array $params * @return string */ function smarty_function_select_priority_images($params, &$smarty) { $priorities = array(PRIORITY_URGENT => lang('Urgent'), PRIORITY_HIGHEST => lang('Highest'), PRIORITY_HIGH => lang('High'), PRIORITY_NORMAL => lang('Normal'), PRIORITY_LOW => lang('Low'), PRIORITY_LOWEST => lang('Lowest'), PRIORITY_HOLD => lang('Hold'), '-99' => lang('Unknown')); $priorities_images = array(PRIORITY_URGENT => 'assets/images/icons/priority/urgent.png', PRIORITY_HIGHEST => 'assets/images/icons/priority/highest.gif', PRIORITY_HIGH => 'assets/images/icons/priority/high.gif', PRIORITY_NORMAL => 'assets/images/icons/priority/normal.gif', PRIORITY_LOW => 'assets/images/icons/priority/low.gif', PRIORITY_LOWEST => 'assets/images/icons/priority/lowest.gif', PRIORITY_HOLD => 'assets/images/icons/priority/hold.png', '-99' => 'assets/images/icons/priority/unknown.png'); //BOF:mod $priority_not_set = false; if ($params['value'] == '0') { $link = mysql_connect(DB_HOST, DB_USER, DB_PASS); mysql_select_db(DB_NAME, $link); $query = "select isnull(priority) as priority_not_set from healingcrystals_project_objects where id='" . (int) $params['name'] . "'"; $result = mysql_query($query, $link); $info = mysql_fetch_Assoc($result); if ($info['priority_not_set'] == '1') { $priority_not_set = true; } mysql_close($link); } if (!$priority_not_set) { //EOF:mod $params['sel-image'] = $priorities_images[$params['value']]; $value = 0; if (isset($params['value'])) { $value = (int) $params['value']; //if($value > PRIORITY_HIGHEST || $value < PRIORITY_HOLD) { if ($value > PRIORITY_URGENT || $value < PRIORITY_HOLD) { $value = 0; } // if } // if //BOF:mod } else { $value = '-99'; $params['sel-image'] = $priorities_images[$value]; } unset($params['value']); //EOF:mod $params['id'] = $params['name']; $obj = new ProjectObject($params['id']); $params['name'] = strtolower($obj->getType()) . 'priorityimages_' . $params['name']; $params['class'] = 'imageList'; $options = array(); $options[] = option_tag('Priority', '-', array('data-skip' => 'true')); foreach ($priorities as $priority => $priority_text) { $option_attribites = $priority == $value ? array('selected' => true) : array(); $option_attribites['data-icon'] = $priorities_images[$priority]; $options[] = option_tag($priority_text, $priority, $option_attribites); } // if return select_box($options, $params); }
function search_posts($term) { $keywords = preg_split('#\\s+#', mysql_real_escape_string($term)); /*print_r($keywords);*/ $title_where = "`post_title` LIKE '%" . implode("%' OR `post_title` LIKE '%", $keywords) . "%'"; $body_where = "`post_body` LIKE '%" . implode("%' OR `post_body` LIKE '%", $keywords) . "%'"; $sql = "SELECT\n\t\t`post_title` AS `title`,\n\t\tLEFT(`post_body`, 100) AS `body`\n\tFROM `posts`;\n\tWHERE {$title_where}\n\tOR {$body_where}"; $result = mysql_query($sql); $results = array(); while (($row = mysql_fetch_Assoc($result)) !== false) { $results[] = $row; } return $results; }
if (!$this->a) { put_error('error in mysql: the query was: "' . $query . '"'); } if ($return == 2) { // returning associative masive while ($this->ret = mysql_fetch_assoc($this->a)) { return $this->ret; } } else { if ($return == 1) { // returning one element, or empty if (!mysql_num_rows($this->a)) { return ''; } $this->ret = mysql_result($this->a, 0); return $this->ret; } else { // simply returns connection descriptor: return $this->a; } } } } $sys = new Sys(); // Primery ispolqzovanija $login = $sys->do_mysql('SELECT login FROM players WHERE id_player = 1;', 1); echo $login . '<br/>'; $q = $sys->do_mysql('SELECT email FROM players'); while ($emails = mysql_fetch_Assoc($q)) { echo $emails['email'] . '<br/>'; }