PHP . SU
Программирование на PHP, MySQL и другие веб-технологии
Страниц (22): В начало « ... 13 14 15 16 [17] 18 19 20 21 ... » В конец
Найдено сообщений: 318
Faraon-san
Отправлено: 02 Апреля, 2015 - 13:03:09 • Тема: Достать Checkbox из БД со значением • Форум: Вопросы новичков
Ответов: 5 Просмотров: 236
PHP:
скопировать код в буфер обмена
<?PHP foreach ( $service as $id => $serv ) : ?>
<input type="checkbox" <?PHP echo $serv [ 'first' ] == 'Да' ? 'checked' : '' ; ?> value="Да" name="first">
<input type="checkbox" <?PHP echo $serv [ 'second' ] == 'Да' ? 'checked' : '' ; ?> value="Да" name="second">
<input type="checkbox" <?PHP echo $serv [ 'third' ] == 'Да' ? 'checked' : '' ; ?> value="Да" name="third">
<input type="checkbox" <?PHP echo $serv [ 'fourth' ] == 'Да' ? 'checked' : '' ; ?> value="Да" name="fourth">
<?PHP endforeach ; ?>
Faraon-san
Отправлено: 02 Апреля, 2015 - 10:31:24 • Тема: Подправить рабочий JS код прокрутки до якоря с отступом сверху • Форум: JavaScript & VBScript
Ответов: 10 Просмотров: 1978
CODE (
javascript ):
скопировать код в буфер обмена
jQuery( function ( $) {
// Bind click handler to menu items
// so we can get a fancy scroll animation
$( '#top-menu' ) .find ( 'a' ) .on ( 'click' , function ( ) {
var topMenuHeight = $( '#top-menu' ) .outerHeight ( ) + 33,
href = $( this ) .attr ( 'href' ) ,
obj = $( '#' + href.split ( '#' ) .pop ( ) ) ,
offsetTop = href === '#' ? 0 : obj.offset ( ) .top - topMenuHeight+ 1 ;
$( '#top-menu' ) .find ( 'li.active' ) .removeClass ( 'active' ) ;
obj.closest ( 'li' ) .addClass ( 'active' ) ;
$( 'html, body' ) .stop ( ) .animate ( {
scrollTop: offsetTop
} , 300) ;
return false ;
} ) ;
} ) ;
Faraon-san
Отправлено: 02 Апреля, 2015 - 10:13:43 • Тема: Подправить рабочий JS код прокрутки до якоря с отступом сверху • Форум: JavaScript & VBScript
Ответов: 10 Просмотров: 1978
CODE (
javascript ):
скопировать код в буфер обмена
jQuery( function ( $) {
// Bind click handler to menu items
// so we can get a fancy scroll animation
$( '#top-menu' ) .find ( 'a' ) .on ( 'click' , ( function ( ) {
var topMenuHeight = $( '#top-menu' ) .outerHeight ( ) + 33,
href = $( this ) .attr ( 'href' ) ,
obj = $( '#' + href.split ( '#' ) .pop ( ) ) ,
offsetTop = href === '#' ? 0 : obj.offset ( ) .top - topMenuHeight+ 1 ;
$( '#top-menu' ) .find ( 'li.active' ) .removeClass ( 'active' ) ;
obj.closest ( 'li' ) .addClass ( 'active' ) ;
$( 'html, body' ) .stop ( ) .animate ( {
scrollTop: offsetTop
} , 300) ;
return false ;
} ) ;
} ) ;
Faraon-san
Отправлено: 02 Апреля, 2015 - 00:36:52 • Тема: Вывод данных в таблицу - как лучше реализовать? • Форум: Программирование на PHP
Ответов: 6 Просмотров: 463
PHP:
скопировать код в буфер обмена
array ( 'period' => 1 , 'interest_rate' => 10.00 , 'sum_min' => 100 , 'currency_id' => 1
) , array ( 'period' => 3 , 'interest_rate' => 11.00 , 'sum_min' => 100 , 'currency_id' => 1
) , array ( 'period' => 1 , 'interest_rate' => 7.00 , 'sum_min' => 100 , 'currency_id' => 3
) , array ( 'period' => 3 , 'interest_rate' => 5.00 , 'sum_min' => 100 , 'currency_id' => 2
) , array ( 'period' => 3 , 'interest_rate' => 6.00 , 'sum_min' => 2000 , 'currency_id' => 2
) , array ( 'period' => 9 , 'interest_rate' => 9.00 , 'sum_min' => 200 , 'currency_id' => 3
) , array ( 'period' => 3 , 'interest_rate' => 8.00 , 'sum_min' => 200 , 'currency_id' => 3
) ) ;
foreach ( $array as $a )
{
$data [ $a [ 'currency_id' ] ] [ $a [ 'sum_min' ] ] [ $a [ 'period' ] ] = $a [ 'interest_rate' ] ;
}
$result = '<table style="width: 500px;"><thead><tr>' ;
$result .= '<th rowspan="2">Сумма взноса</th>' ;
$result .= '<th colspan="3">Срок/Процентная ставка</th>' ;
$result .= '</tr><tr>' ;
$result .= '<th>1 месяц</th>' ;
$result .= '<th>3 месяца</th>' ;
$result .= '<th>9 месяцев</th>' ;
$result .= '</tr></thead><tbody>' ;
foreach ( $data as $a => $b )
{
$result .= '<tr><td colspan="4">currency_id=' . $a . '</td></tr>' ;
foreach ( $b as $c => $d )
{
$result .= '<tr>' ;
$result .= '<td>' . $c . '</td>' ;
$count = array ( 1
=> false , 3
=> false , 9
=> false ) ; $empty = '<td>-</td>' ;
foreach ( $d as $e => $f )
{
switch ( $e )
{
case 1:
$result .= '<td>' . number_format ( $f , 2 , ',' , '' ) . '%</td>' . PHP_EOL
; $count [ 1] = true ;
break ;
case 3:
if ( ! $count [ 1] ) {
$result .= $empty ;
$count [ 1] = true ;
}
$result .= '<td>' . number_format ( $f , 2 , ',' , '' ) . '%</td>' . PHP_EOL
; $count [ 3] = true ;
break ;
case 9:
if ( ! $count [ 1] ) {
$result .= $empty ;
$count [ 1] = true ;
}
if ( ! $count [ 3] ) {
$result .= $empty ;
$count [ 3] = true ;
}
$result .= '<td>' . number_format ( $f , 2 , ',' , '' ) . '%</td>' . PHP_EOL
; $count [ 9] = true ;
break ;
}
}
foreach ( $count as $k => $v ) {
if ( ! $v ) {
$result .= $empty ;
}
}
$result .= '</tr>' ;
}
}
$result .= '</tbody></table>' ;
echo $result ;
Faraon-san
Отправлено: 01 Апреля, 2015 - 23:37:44 • Тема: Есть ли аналог функции str_word_count ? • Форум: Вопросы новичков
Ответов: 6 Просмотров: 250
решение конечно не 100%, но можно точки, запятые, дефисы, знаки вопроса и т.д. заменить на пробелы, потом где 2 пробела и более заменить на один, а потом уже разбивать на массив.
Faraon-san
Отправлено: 01 Апреля, 2015 - 23:24:12 • Тема: Сохранение массива в файл • Форум: Вопросы новичков
Ответов: 4 Просмотров: 147
PHP:
скопировать код в буфер обмена
include 'config.php';
$handler = fopen('config.php', 'w');
$config['meta'] = 'charset="utf-8"';
fwrite($handler, "
<?PHP \n\
$config = array ( \n
"); foreach($config as $key => $value ) {
$space = str_repeat(' ', 4);
fwrite($handler , " { $space } '{$key}' => '{$value}' , \n");
}
fwrite($handler , " ) ; \n?> ");
fclose($handler);
Faraon-san
Отправлено: 01 Апреля, 2015 - 23:05:23 • Тема: Сохранение массива в файл • Форум: Вопросы новичков
Ответов: 4 Просмотров: 147
PHP:
скопировать код в буфер обмена
include 'config.php';
$handler = fopen('config.php', 'w');
fwrite($handler, "
<?PHP \n\
$config = array ( \n
"); foreach($config as $key => $value ) {
$space = str_repeat(' ', 4);
fwrite($handler , " { $space } '{$key}' => '{$value}' , \n");
}
fwrite($handler , " ) ; \n?> ");
fclose($handler);
Страниц (22): В начало « ... 13 14 15 16 [17] 18 19 20 21 ... » В конец
Powered by ExBB FM 1.0 RC1. InvisionExBB