Posts Tagged with select

Displaying 1-10 of 24 results.
Resolved: Dhtmlx attachform select option
posted by admin on December 9, 2016
I have DHtmlx form, and I have select option part of form. How I can downlload data from db and fill my select options
My form

var str = [
{ type:"block" , name:"bl1", list:[

]},
{ type:"input" , name:"id", label: "ID", hidden: true},
{ type:"input" , name:"status", label: "Status:", readonly: true, width: 287, labelWidth: 70, value: "Not set"},
{ type:"input" , name:"count", label: "Count"},
{ type:"select" , name:"worker", label: "Worker"},
{ type:"button" , name:"save", value:"End process", width:"320" }
];

form_1 = tab_x.attachForm(str);

I dont want load content from another file by select attribute, i want to upload int main file and output thereRead more
Resolved: Css pre last child
posted by admin on November 7, 2016
I want to get pre-last child of children elements
Example:

<table>
<tr><td>1<td><td>2<td><td>3<td><td>...<td><td>n-1<td><td>n<td></tr><!-- 1 -->
<tr><td>1<td><td>2<td><td>3<td><td>...<td><td>n-1<td><td>n<td></tr><!-- 2 -->
<tr><td>1<td><td>2<td><td>3<td><td>...<td><td>n-1<td><td>n<td></tr><!-- 3 -->
...//<!-- ... -->
<tr><td>1<td><td>2<td><td>3<td><td>...<td><td>n-1<td><td>n<td></tr><!-- m -->
<tr><td>1<td><td>2<td><td>3<td><td>...<td><td>n-1<td><td>n<td></tr><!-- m - 1 -->
</table>

I want to get all pre td elements selector in css styles, like

table tr td:last-child(-1){
/* to do */
}
Read more
Wiki: Yii 1.1 new CDbCriteriawiki
posted by admin on November 7, 2016

// создаем экземпляр класса CDbCriteria
$criteria = new CDbCriteria;
// выбираемые все столбцы из всех таблиц, участвующих в запросе
$criteria->select = '*';
//$criteria->select = array('post.id', 'post.category_id', 'post.user_id', 'post.title', 'user.name');
//$criteria->select = 'post.id, post.category_id, post.user_id, post.title, user.name';
// псевдоним(алиас) для текущей таблицы
$criteria->alias = 'post';
// выбираем только неповторяющиеся строки данных
$criteria->distinct = true;
// задаем условие запроса
$criteria->condition = 'post.is_hide = :is_hide AND post.user_id = :author_id';
// группируем
$criteria->group = 'post.category_id';
// условие для GROUP BY
$criteria->having = 'post.viwed > 100';
// задаем соединение с другой(ими) таблицами
$criteria->join = 'LEFT JOIN users as user ON user.id = post.user_id';
// максимальное количество возвращаемых записей
$criteria->limit = 20;
// смещение, с которого будут возвращаться записи
$criteria->offset = 5;
// сортировки результатов запроса
$criteria->order = 'post.date_create';
// параметры для замены в SQL выражении, для condition
$criteria->params = array(':is_hide'=>0, ':author_id'=>Yii::app()->user->id);
// внешние таблицы должны быть связаны с первичной таблицей в одном SQL-запросе
$criteria->together = true;
// получение связанных объектов в режиме "жадной" загрузки
$criteria->with = array('profile', 'comments', 'category');
// добавляем условие between (диапазон)
$criteria->addBetweenCondition('post.date_update', '09-12-2011', '09-12-2015');
// добавляем условие для сравнения переданного списка со значениями столбцов
$criteria->addColumnCondition(array('status'=>1), 'AND')
// добавляем условие IN к уже имеющемуся (condition)
$criteria->addInCondition('post.category_id', array('6', '24', '247'), 'OR');
// добавляем условие к уже имеющемуся (condition)
$criteria->addCondition("count_comments <= :count_comments");
// сливает критерий с другим
if($_POST['search_text']){
$criteriaSearch = new CDbCriteria();
$criteriaSearch->addSearchCondition('description', $_POST['search_text']. true, 'AND', 'LIKE');
$criteria->mergeWith($criteriaSearch, 'AND');
}
$posts = Post::model()->findAll($criteria);
Read more
Not Resolved: MySQL count where columns fields have same value
posted by admin on November 1, 2016
I have rows, and I want count my select with criteria IN and want to count rows, which is having same values for all rows
Example:

id name lastname age
1 Abc defghij 12
2 Def asdasd 15
3 Ghi qwewqeq 18
4 Abc zzzzz 12
5 Abc yyy 12
6 Abc uuuu 12

IN array

1, 4, 5, 6

Same fields:

`name`, `age`

I want to see RESULTS LIKE
Result SELECT:

id name lastname age
1 Abc defghij 12
4 Abc zzzzz 12
5 Abc yyy 12

Result SELECT COUNT(*):

3
Read more
Wiki: Bootstrap Form Inputswiki
posted by admin on October 12, 2016
Supported Form Controls
Bootstrap supports the following form controls:
  • input
  • textarea
  • checkbox
  • radio
  • select


Bootstrap Input
Bootstrap supports all the HTML5 input types: text, password, datetime, datetime-local, date, month, time, week, number, email, url, search, tel, and color.
Note: Inputs will NOT be fully styled if their type is not properly declared!

<div class="form-group">
<label for="usr">Name:</label>
<input type="text" class="form-control" id="usr">
</div>
<div class="form-group">
<label for="pwd">Password:</label>
<input type="password" class="form-control" id="pwd">
</div>


Bootstrap Textarea
The following example contains a textarea:

<div class="form-group">
<label for="comment">Comment:</label>
<textarea class="form-control" rows="5" id="comment"></textarea>
</div>

Bootstrap Checkboxes
Checkboxes are used if you want the user to select any number of options from a list of preset options.

The following example contains three checkboxes. The last option is disabled:

<div class="checkbox">
<label><input type="checkbox" value="">Option 1</label>
</div>
<div class="checkbox">
<label><input type="checkbox" value="">Option 2</label>
</div>
<div class="checkbox disabled">
<label><input type="checkbox" value="" disabled>Option 3</label>
</div>

Use the .checkbox-inline class if you want the checkboxes to appear on the same line:

<label class="checkbox-inline"><input type="checkbox" value="">Option 1</label>
<label class="checkbox-inline"><input type="checkbox" value="">Option 2</label>
<label class="checkbox-inline"><input type="checkbox" value="">Option 3</label>

Bootstrap Radio Buttons
Radio buttons are used if you want to limit the user to just one selection from a list of preset options.

The following example contains three radio buttons. The last option is disabled:

<div class="radio">
<label><input type="radio" name="optradio">Option 1</label>
</div>
<div class="radio">
<label><input type="radio" name="optradio">Option 2</label>
</div>
<div class="radio disabled">
<label><input type="radio" name="optradio" disabled>Option 3</label>
</div>

Use the .radio-inline class if you want the radio buttons to appear on the same line:

<label class="radio-inline"><input type="radio" name="optradio">Option 1</label>
<label class="radio-inline"><input type="radio" name="optradio">Option 2</label>
<label class="radio-inline"><input type="radio" name="optradio">Option 3</label>

Bootstrap Select List
Select lists are used if you want to allow the user to pick from multiple options.

The following example contains a dropdown list (select list):

<div class="form-group">
<label for="sel1">Select list:</label>
<select class="form-control" id="sel1">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
</select>
</div>
Read more
Resolved: Yii 1.1 How to add html tag in CMenu menu item label text?
posted by admin on October 10, 2016
I have CMenu and I try to add html tags to menu items label and like this

<?php $this->widget('zii.widgets.CMenu',array(
'htmlOptions'=>array('class'=>'nav navbar-nav'),
'items'=>array(
array('label'=>'Главная', 'url'=>array('/')),
array('label'=>'Склады <span class="caret"></span>', 'url'=>array('#'),
'itemOptions'=>array('class'=>'dropdown'),
'linkOptions'=> array(
'class' => 'dropdown-toggle',
'data-toggle' => 'dropdown',
),
...
),
)); ?>

Output show encoded html with html character:

Склады <span class="caret"></span>
Read more
Wiki: Задача MySQL. Выбрать из таблицы те книги, у которых два и более автораwiki
posted by admin on August 24, 2016
Таблица авторов:

CREATE TABLE `tbl_author` (
`id` int(10) NOT NULL,
`name` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

ALTER TABLE `tbl_author`
ADD PRIMARY KEY (`id`);


Таблица книг

CREATE TABLE `tbl_book` (
`id` int(10) NOT NULL,
`name` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

ALTER TABLE `tbl_book`
ADD PRIMARY KEY (`id`);


Таблица связей межу таблицей книг и авторов

CREATE TABLE `tbl_book_author` (
`id` int(10) NOT NULL,
`book_id` int(10) NOT NULL,
`author_id` int(10) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

ALTER TABLE `tbl_book_author`
ADD PRIMARY KEY (`id`),
ADD KEY `book_id` (`book_id`),
ADD KEY `author_id` (`author_id`);


Решение

SELECT book.id, book.name, COUNT(ba.author_id) AS cnt FROM `tbl_book_author` ba
LEFT JOIN tbl_book book
ON book.id = ba.book_id
GROUP BY ba.book_id
HAVING cnt > 1
Read more
Resolved: MySQL Like string in multiple value by one script
posted by admin on June 18, 2016
I always thought that you could use OR in a LIKE statment to query things in MySQL. So, if I wanted to compare multiple fields in a row to 1 keyword or term:

SELECT * FROM MyTable WHERE Column1 OR Column2 LIKE '%keyword%';

and if I had an array of words to compare:

SELECT * FROM MyTable WHERE Column1 OR Column2 LIKE '%keyword1%'
AND Column1 OR Column2 LIKE '%keyword2%';

I don't believe that syntax is correct, however. Is there an efficient method of writing this aside from something like:

SELECT * FROM MyTable WHERE Column1 LIKE '%keyword1%' OR Column2 LIKE
'%keyword1%' AND Column1 LIKE '%keyword2%' OR Column2 LIKE '%keyword2%';
Read more
Resolved: Select last row in MySQL
posted by admin on May 21, 2016
How can I SELECT the last row in a MySQL table?Read more
Resolved: MySQL - Count Number of Unique Values
posted by admin on May 21, 2016
If I have three columns:

orderNumber, name, email

and I would like to count how many unique emails are in the table how would I go about doing so?

A statement like:

SELECT count(email) FROM orders

gives me the total count.
I tried

SELECT DISTINCT count(email) FROM orders

but that does not seem to be giving me the numbers I am expecting.Read more