Форум программистов, компьютерный форум, киберфорум
PHP для начинающих
Войти
Регистрация
Восстановить пароль
Карта форума Темы раздела Блоги Сообщество Поиск Заказать работу  
 
Рейтинг 4.67/3: Рейтинг темы: голосов - 3, средняя оценка - 4.67
0 / 0 / 1
Регистрация: 25.01.2014
Сообщений: 19
1

Переменная

26.01.2014, 02:16. Показов 623. Ответов 2
Метки нет (Все метки)

Author24 — интернет-сервис помощи студентам
На сайте http://skidki-lipetsk.ru/
Сверху есть "Рубрики" и "Большие скидки", а между ними "57". Так вот, это число, которое суммирует все купоны на сайте. (А всего то на сайте 16 купонов, но они разбросаны на разние подрубрики)
А как сделать, чтобы оно не сумировало, а выводило кол-во купонов только?
Вот строчка, от которой всё зависит:
PHP
1
            <a class="hd-logo" href="/">skidki-lipetsk.ru</a>                               {foreach from=$rubrics item=t name=loop}                    {if $t.id == -1}<div id="cats" class="cat-all{if $t.id == $rubric_id} active{/if}">                                             <a href="#" class="hd-reg-btn button-white" onclick="show_menu(menu, event);"><span><b>РУБРИКИ</b></span></a>                                                <sup class="count">{$t.count}</sup>                     </div>                                                                  <ul id="menu" class="hidden">                   {else}<li class="cat-{$t.alias}{if $t.id == $rubric_id} active{/if}">                                           <a href="/category/{$t.alias}">{$t.cname}                                               <sup>{$t.count}</sup>                                               </a>                                            </li>{/if}              {/foreach}                                  </ul>                               <a id="big_skidki" href="http://skidki-lipetsk.ru/category/bigdiscount" class="hd-reg-btn button-white"><span><b>БОЛЬШИЕ СКИДКИ</b></span></a>                                 <!-- Выбор города
0
Programming
Эксперт
94731 / 64177 / 26122
Регистрация: 12.04.2006
Сообщений: 116,782
26.01.2014, 02:16
Ответы с готовыми решениями:

переменная+переменная =
Здраствуйте я уже 5 часа ломаю голову как решить проблему $trow1 = array (&quot;type&quot; =&gt;...

Переменная
Всем привет! Как выпадающему списку и строке для ввода можно присвоить переменную? Я не могу понять...

Статическая переменная
&lt;html&gt;&lt;body&gt; &lt;?php function selfcount() { static $count = 0; $count++; echo $count; }...

Не работает переменная
Подскажите почему ничего не отображает скрипт &lt;?php echo $_SERVER; ?&gt; Стоит Апач 2. Добавлено...

2
Эксперт PHP
5753 / 4133 / 1507
Регистрация: 06.01.2011
Сообщений: 11,276
26.01.2014, 13:30 2
slavpas, это шаблон. Счёт купонов идёт не в шаблоне, а в php коде.
0
0 / 0 / 1
Регистрация: 25.01.2014
Сообщений: 19
26.01.2014, 17:32  [ТС] 3
Вот в этом коде и надо править, только как править ?
PHP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
<?php
require_once (BASEDIR . "/class/Shares.Class.php");
global $tmpl;
global $db;
 
$shares = new Shares();
 
$rubric_id = $_GET['action'];
$location = $GLOBALS['g_city_id'];
 
$rubric_name = '';
if(!is_numeric($rubric_id)) {
    $matches = array();
    preg_match('/[0-9]+$/', $rubric_id, $matches);
    if(count($matches) == 1) {
        $pagenum = $matches[0];
        $rubric_id = substr($rubric_id, 0, strlen($rubric_id) - strlen($pagenum));
    } else
        $pagenum = 1;
 
    $rubric_name = $rubric_id;
 
    $q = "SELECT id FROM `rubrics` WHERE alias = '$rubric_id'";
    $res = mysql_query($q);
    if(mysql_num_rows($res)<1) {
        $error_404 = true;
    }
    $row = mysql_fetch_assoc($res);
    if(!$row or !is_array($row) or count($row) <= 0) {
        $rubric_id = -1;
    } else
        $rubric_id = $row['id'];
    $q = false;
    $res = false;
    $row = false;
} else {
    $pagenum = ((isset($_GET['param'])) && (is_numeric($_GET['param']))) ? trim($_GET['param']) : 1;
}
 
if ($rubric_id > 0) {
    $side_tags = $shares->get_tags($rubric_id);
    $tmpl->assign("side_tags", $side_tags);
    $seo_content = $shares->get_seo_content();
    $tmpl->assign('seo_content', $seo_content);
    $tmpl->assign('title', $seo_content['title']);
}
 
$_REQUEST['page'] = $pagenum;
$index_shares = $shares->index_shares($location, $user, $pagenum, $rubric_id);
 
$total_shares = $shares->index_shares_count($location, $pagenum, $rubric_id);
$shares -> pagination('/category/' . ($rubric_name != '' ? $rubric_name : "$rubric_id/"), $total_shares);
//$this->tmpl->assign('pager', $pagination);
 
//start_tpl
$sql_st = $db -> Query("SELECT start_tpl FROM " . PREFIX . "_areas WHERE area_id = '{$area}'");
$row_st = $sql_st -> fetchrow();
$start_tpl = $row_st -> start_tpl;
$start_tpl = ($start_tpl == '' || !file_exists(BASEDIR . '/templates/' . $THEME . '/start/' . $start_tpl)) ? 'startpage.tpl' : $start_tpl;
 
if(isset($index_shares[0] -> shares_id)) {
 
    $nnum = 0;
    foreach ($index_shares as $key => $v) {
 
        $tpl_items_now[$key]['name'] = $v -> name;
 
        //получить кол-во комментариев в акции
        $sql = "SELECT count(id) AS count FROM comments WHERE parent_id=" . $v -> shares_id . " and comment_id=0";
        $result = mysql_query($sql);
        $row = mysql_fetch_assoc($result);
        $tpl_items_now[$key]['comments'] = $row["count"];
        //получить кол-во комментариев в акции
        $tpl_items_now[$key]['id'] = $v -> shares_id;
        $tpl_items_now[$key]['url'] = $shares->makeURL($v->shares_id, $v->alias);
 
        $image_arr = explode(', ', $v -> img);
        $tpl_items_now[$key]['img'] = $image_arr;
        //[0];
        unset($image_arr);
 
        //$tpl_items_now[$key]['price']=$v->price;
        $tpl_items_now[$key]['style'] = ((($nnum++) % 2) == 0) ? 'act1' : 'act2';
        $tpl_items_now[$key]['skidka'] = $v -> skidka;
        $time = time();
        if(strtotime($v->autodate) > $time) {
            $tpl_items_now[$key]['annonce'] = true;
            $last_time = strtotime($v->autodate);
        } else {
            $last_time = strtotime($v->last_time_can_buy);
        }
        $tpl_items_now[$key]['last_time'] = ($last_time < $time) ? date("d F, Y, H:i:s", $time) : date("d F, Y, H:i:s", $last_time);
        $tpl_items_now[$key]['now_time'] = date("d F, Y, H:i:s", $time);
        $tpl_items_now[$key]['timeout'] = ($last_time < $time)?1:0;
        $tpl_items_now[$key]['days_remain'] = floor(($last_time - $time) / 86400);
 
        $tpl_items_now[$key]['degrees'] = round(($last_time - $time) / 43200) * 45;
        if ($tpl_items_now[$key]['degrees'] < 45) $tpl_items_now[$key]['degrees'] = 45;
        if ($tpl_items_now[$key]['degrees'] > 315) $tpl_items_now[$key]['degrees'] = 315;
 
        $tpl_items_now[$key]['new'] = $v->new;
        $tpl_items_now[$key]['favourite'] = $v->favourite;
 
        $pr = $v -> price;
        $mm = array();
        $symb = false;
        if(preg_match('/(.*)руб\.?$/s', $pr, $mm)) {
            $mm = $mm[1];
            $symb = true;
        } elseif(preg_match('/(.*)р\.?$/s', $pr, $mm)) {
            $mm = $mm[1];
            $symb = true;
        } elseif(preg_match('/(.*)рублей$/s', $pr, $mm)) {
            $mm = $mm[1];
            $symb = true;
        } elseif(preg_match('/(.*)рубля$/s', $pr, $mm)) {
            $mm = $mm[1];
            $symb = true;
        } elseif(preg_match('/(.*)рубль$/s', $pr, $mm)) {
            $mm = $mm[1];
            $symb = true;
        } elseif(preg_match('/(.*[0-9\.\,]+)$/s', $pr, $mm)) {
            $mm = $mm[1];
            $symb = true;
        } else {
            $mm = $pr;
        }
        $tpl_items_now[$key]['price'] = trim($mm);
        $tpl_items_now[$key]['is_r'] = ($symb) ? '1' : '0';
 
        $tpl_items_now[$key]['price_cuppon'] = str_replace('.', ',', sprintf('%d', (float)$v -> price_out));
 
        $tpl_items_now[$key]['description'] = $v -> description;
        
        $tpl_items_now[$key]['options'] = $v->options;
        if ($v->partners == 854) $tpl_items_now[$key]['restomesto'] = true;
 
        $w = trim(isset($v -> www) ? $v -> www : '');
        $m = array();
        if(strlen($w) > 0) {
            if(preg_match('@^http[s]?://(.*)@', $w, $m)) {
                $wt = $m[1];
            } else {
                $wt = $w;
                $w = 'http://' . $w;
            }
        } else {
            $wt = '';
        }
 
        $tpl_items_now[$key]['www'] = $w;
        $tpl_items_now[$key]['www_title'] = $wt;
        $tpl_items_now[$key]['skype'] = isset($v -> skype) ? $v -> skype : '';
        $tpl_items_now[$key]['email'] = isset($v -> email) ? $v -> email : '';
        $tpl_items_now[$key]['place_info'] = $v -> place_info;
 
        if(intval($v -> price) != 0) {
            $tpl_items_now[$key]['is_unlimited'] = 0;
        } else {
            $tpl_items_now[$key]['is_unlimited'] = 1;
        }
 
        if(intval($v -> price) != 0 && intval($v -> skidka) != 0) {
            $tpl_items_now[$key]['econom'] = $tpl_items_now[$key]['price'] - $tpl_items_now[$key]['price_cuppon'];
        } else {
            $tpl_items_now[$key]['econom'] = $v -> skidka;
        }
 
        $summ = 0;
        foreach ($v->subActions as $subAction) {
            $summ = $summ + $subAction -> bought_cuppon_count;
        }
 
        $cuppons_bought = ($summ > 0 && $v -> subActions) ? $summ : $shares -> cuppons_count_bought($v -> shares_id) -> num;
        if($v->fake_maxorders) {
            $cuppons_left = max($v->fake_maxorders - $cuppons_bought, 0);
            $tpl_items_now[$key]['cuppons_left'] = $cuppons_left;
            $tpl_items_now[$key]['pf']=$shares->pluralForm($cuppons_left, 'купон', 'купона', 'купонов');
        } else {
            $tpl_items_now[$key]['cuppons_count_bought'] = $cuppons_bought;
            $tpl_items_now[$key]['pf']=$shares->pluralForm($cuppons_bought, 'купон', 'купона', 'купонов');
        }
 
        /*
        // Progress bar
        // Total length = 7 * 30 = 210px
        $bp = min(1, $cuppons_bought / $v -> cuppon_count);
        $bp_left = (int)($bp * 30) * 7;
        $tpl_items_now[$key]['cuppons_buy_percent'] = sprintf('%d', $bp_left);
        $tpl_items_now[$key]['rcuppons_buy_percent'] = sprintf('%d', 210 - $bp_left);
        */
        
        $tpl_items_now[$key]['js_num'] = '';//$key+1;
        $tpl_items_now[$key]['begin_time_cuppons'] = date("d/m/Y", strtotime($v -> begin_time_cuppons));
        $tpl_items_now[$key]['last_time_cuppons'] = date("d/m/Y", strtotime($v -> last_time_cuppons));
        
        /*
        $tpl_items_now[$key]['width_last_time'] = ceil((time() - strtotime($v -> add_time)) / (strtotime($v -> last_time) - strtotime($v -> add_time)) * 100);
        $width_last_time_cuppons = ceil((time() - strtotime($v -> begin_time_cuppons)) / (strtotime($v -> last_time_cuppons) - strtotime($v -> begin_time_cuppons)) * 100);
        if($width_last_time_cuppons < 0) {
            $width_last_time_cuppons = 0;
        }
        $tpl_items_now[$key]['width_last_time_cuppons'] = $width_last_time_cuppons;
        */
        
        $tpl_items_now[$key]['subActions'] = $v->subActions;
    }
 
    $tmpl->assign("tpl_items_now", $tpl_items_now);
    $tmpl->assign('shares_per_page', $num_on_page);
    
    $start_tpl = 'standard2.tpl';
} else {
    $start_tpl = 'standard_noshares.tpl';
}
 
$tmpl->assign("is_front", 1);
$tmpl->assign('list_view', (isset($_COOKIE['list_view']) && $_COOKIE['list_view'] == 'line') ? 'line' : 'block');
$tmpl->assign("content", $tmpl->fetch('start/' . $start_tpl));
0
26.01.2014, 17:32
IT_Exp
Эксперт
87844 / 49110 / 22898
Регистрация: 17.06.2006
Сообщений: 92,604
26.01.2014, 17:32
Помогаю со студенческими работами здесь

Не доступна переменная
Добрый день! Со вчерашнего дня не могу понять в чем дело. В подключаемом файле не везде видна...

Переменная в цикле
В общем, хочу сделать счётчик. Но выводит только последнее значение переменной. foreach($groups...

Переменная в изображении
Есть переменная. Есть jpg. Переменная меняется пару раз в неделю. Как сделать отображение...

Глобальная переменная
Здраствуйте, вот интересует такой вопрос: можно ли как-то переменную сделать глобальной так, чтобы...


Искать еще темы с ответами

Или воспользуйтесь поиском по форуму:
3
Ответ Создать тему
КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin
Copyright ©2000 - 2024, CyberForum.ru