Модераторы: skyboy, MoLeX, Aliance, ksnk
  

Поиск:

Ответ в темуСоздание новой темы Создание опроса
> Undefined variable 
:(
    Опции темы
GodEatGod
Дата 12.10.2007, 10:56 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Шустрый
*


Профиль
Группа: Участник
Сообщений: 67
Регистрация: 15.6.2007

Репутация: 1
Всего: 1



Код

$today1=mssql_query('SELECT count(id) as kol, sum(cast(stoim as numeric(10,2)))/60 as amount  from table1 where convert(varchar(10), getdate(),104)=convert(varchar(10), date_reg,104) and not date is null');
     $today2=mssql_query('SELECT count(id) as kol, sum(cast(stoim as numeric(10,2)))/60 as amount  from table1 where convert(varchar(10), getdate(),104)=convert(varchar(10), date_reg,104) and date is null');
     $today3=mssql_query('SELECT count(id) as kol, sum(cast(stoim as numeric(10,2)))/60 as amount  from table1 where convert(varchar(10), getdate(),104)=convert(varchar(10), date_reg,104)');



      
Код

  echo '<tr>';
        
        for ($i=1; $i<=3; $i++)
        
        {
        
                $res_today=mssql_fetch_assoc($today.$i);

            
            echo "<td>".$res_today['kol']."</td>"; 
            echo '<td>'.$res_today['amount'].'</td>'; 
         
            
        }
        
        echo '</tr>';

ошибка Undefined variable: today
что исправить?

Это сообщение отредактировал(а) GodEatGod - 12.10.2007, 10:59
PM MAIL   Вверх
olegop
Дата 12.10.2007, 11:03 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Новичок



Профиль
Группа: Участник
Сообщений: 46
Регистрация: 2.10.2007
Где: ПМР, Тирасполь

Репутация: нет
Всего: нет



Код

$today[1]=mssql_query('SELECT count(id) as kol, sum(cast(stoim as numeric(10,2)))/60 as amount  from table1 where convert(varchar(10), getdate(),104)=convert(varchar(10), date_reg,104) and not date is null');
     $today[2]=mssql_query('SELECT count(id) as kol, sum(cast(stoim as numeric(10,2)))/60 as amount  from table1 where convert(varchar(10), getdate(),104)=convert(varchar(10), date_reg,104) and date is null');
     $today[3]=mssql_query('SELECT count(id) as kol, sum(cast(stoim as numeric(10,2)))/60 as amount  from table1 where convert(varchar(10), getdate(),104)=convert(varchar(10), date_reg,104)');


Код

  echo '<tr>';
        
        for ($i=1; $i<=3; $i++)
        
        {
        
                $res_today=mssql_fetch_assoc($today[$i]);

            
            echo "<td>".$res_today['kol']."</td>"; 
            echo '<td>'.$res_today['amount'].'</td>'; 
         
            
        }
        
        echo '</tr>';


Попробуй так 
PM MAIL   Вверх
GodEatGod
Дата 12.10.2007, 11:33 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Шустрый
*


Профиль
Группа: Участник
Сообщений: 67
Регистрация: 15.6.2007

Репутация: 1
Всего: 1



Undefined variable: today

опять
PM MAIL   Вверх
comcon1
Дата 12.10.2007, 11:33 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Опытный
**


Профиль
Группа: Участник
Сообщений: 838
Регистрация: 11.6.2005
Где: Москва ДАС-МГУ

Репутация: нет
Всего: 17



Хех. Ну а если ИМЕННО ТАК, как ты хочешь ( хотя это извращение):
Код

  echo '<tr>';
        
        for ($i=1; $i<=3; $i++)
        
        {
                $var = "today".$i;
                $res_today=mssql_fetch_assoc($$var);
            
            echo "<td>".$res_today['kol']."</td>"; 
            echo '<td>'.$res_today['amount'].'</td>'; 
         
            
        }
        
        echo '</tr>';



--------------------
PM MAIL   Вверх
olegop
Дата 12.10.2007, 11:38 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Новичок



Профиль
Группа: Участник
Сообщений: 46
Регистрация: 2.10.2007
Где: ПМР, Тирасполь

Репутация: нет
Всего: нет



GodEatGod, проверьте что возвращает переменная $today после присовоения запросов 

Код

$today[1]=mssql_query('SELECT count(id) as kol, sum(cast(stoim as numeric(10,2)))/60 as amount  from table1 where convert(varchar(10), getdate(),104)=convert(varchar(10), date_reg,104) and not date is null');
     $today[2]=mssql_query('SELECT count(id) as kol, sum(cast(stoim as numeric(10,2)))/60 as amount  from table1 where convert(varchar(10), getdate(),104)=convert(varchar(10), date_reg,104) and date is null');
     $today[3]=mssql_query('SELECT count(id) as kol, sum(cast(stoim as numeric(10,2)))/60 as amount  from table1 where convert(varchar(10), getdate(),104)=convert(varchar(10), date_reg,104)');

if ($today[1] && $today[2] && $today[3]) echo 1; else echo 0;


если вернется ноль, то проверяйте сами запросы к базе, может они не корректны
PM MAIL   Вверх
GodEatGod
Дата 12.10.2007, 11:43 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Шустрый
*


Профиль
Группа: Участник
Сообщений: 67
Регистрация: 15.6.2007

Репутация: 1
Всего: 1



я понимаю) спасибо.

не могу найти способ оптимизировать:

Код

$today1=mssql_query('SELECT count(id) as kol, sum(cast(stoim as numeric(10,2)))/60 as amount  from table1 where convert(varchar(10), getdate(),104)=convert(varchar(10), date_reg,104) and not date is null');
     $today2=mssql_query('SELECT count(id) as kol, sum(cast(stoim as numeric(10,2)))/60 as amount  from table1 where convert(varchar(10), getdate(),104)=convert(varchar(10), date_reg,104) and date is null');
     $today3=mssql_query('SELECT count(id) as kol, sum(cast(stoim as numeric(10,2)))/60 as amount  from table1 where convert(varchar(10), getdate(),104)=convert(varchar(10), date_reg,104)');


есть еще 

Код

$yesterday1=mssql_query('SELECT count(id) as kol, sum(cast(stoim as numeric(10,2)))/60 as amount  from table1 where convert(varchar(10), getdate()-1,104)=convert(varchar(10), date_reg,104) and not date is null');
     $yesterday2=mssql_query('SELECT count(id) as kol, sum(cast(stoim as numeric(10,2)))/60 as amount  from table1 where convert(varchar(10), getdate()-1,104)=convert(varchar(10), date_reg,104) and date is null');
     $yesterday3=mssql_query('SELECT count(id) as kol, sum(cast(stoim as numeric(10,2)))/60 as amount  from table1 where convert(varchar(10), getdate()-1,104)=convert(varchar(10), date_reg,104)');



а выводить нужно в таблицу:
            готово        не готово      итого            

сегодня
вчера
(где not date is null -готово, date is null-нет)
как лучше поступить?


Это сообщение отредактировал(а) GodEatGod - 12.10.2007, 11:53
PM MAIL   Вверх
  
Ответ в темуСоздание новой темы Создание опроса
Правила форума "PHP"
Aliance
IZ@TOP
skyboy
SamDark
MoLeX

Новичкам:

  • PHP редакторы собираются и обсуждаются здесь
  • Электронные книги по PHP, документацию можно найти здесь
  • Интерпретатор PHP, полную документацию можно скачать на PHP.NET

Важно:

  • Не брезгуйте пользоваться тегами [code=php]КОД[/code] для повышения читабельности текста/кода.
  • Перед созданием новой темы воспользуйтесь поиском и загляните в FAQ
  • Действия модераторов можно обсудить здесь

Внимание:

  • Темы "ищу скрипт", "подскажите скрипт" и т.п. будут переноситься в форум "Web-технологии"
  • Темы с именами: "Срочно", "помогите", "не знаю как делать" будут УДАЛЯТЬСЯ

Если Вам понравилась атмосфера форума, заходите к нам чаще! С уважением, IZ@TOP, skyboy, SamDark, MoLeX, awers.

 
0 Пользователей читают эту тему (0 Гостей и 0 Скрытых Пользователей)
0 Пользователей:
« Предыдущая тема | PHP: Общие вопросы | Следующая тема »


 




[ Время генерации скрипта: 0.0527 ]   [ Использовано запросов: 22 ]   [ GZIP включён ]


Реклама на сайте     Информационное спонсорство

 
По вопросам размещения рекламы пишите на vladimir(sobaka)vingrad.ru
Отказ от ответственности     Powered by Invision Power Board(R) 1.3 © 2003  IPS, Inc.