ALT Linux Community general discussions
 help / color / mirror / Atom feed
From: Alexey Morsov <samurai@ricom.ru>
To: community@altlinux.ru
Subject: Re: [Comm] Программирование на PHP.
Date: Wed, 26 May 2004 10:44:02 +0400
Message-ID: <40B43CB2.4010409@ricom.ru> (raw)
In-Reply-To: <40B2BF15.3080502@krasmail.ru>


Shushenskoe USZN wrote:

> Alexey Morsov пишет:
> 
>> Shushenskoe USZN wrote:
> 
> ...............
> 
>> Ну во-первых попробуй заменить:
>>  $i = 0;
>>   while ($i < $num) {
>>         $row = pg_fetch_array($sql_result, $i);
>> на:
>> $i=0;
>> while ($row = pg_fetch_array($sql_result, $i, PGSQL_ASSOC)) {
>>     echo $row["your_field"] // зачем заводить новые переменные?
>>     echo ...
>>     $++;
>> }
> 
> Мне же надо, чтобы эти данные отображались в хтмл-форме, тогда будет, 
> наверное,
> так ?
> $i = 0;
>   while ($row = pg_fetch_array($sql_result, $i, PGSQL_ASSOC)) {
>                echo "<TR>
>               <TD>"echo $row["date_in"]"</TD>
>               <TD>"echo $row["sender"]"</TD>
>               <TD>"echo $row["name_file"]"</TD>
>               <TD>"echo $row["date_out"]"</TD>
>               <TD>"echo $row["number_out"]"</TD>
>               <TD>"echo $row["opisanie"]"</TD>
>               <TD><a 
> href=\"showedit.php?nn=$nn&date_in=$date_in&number_out=$number_out&opisanie=$opisanie&sender=$sender&date_out=$date_out&otmetka=$otmetka&name_file=$name_file\">Edit</a></TD> 
> 
>               </TR>
>              ";
>         $i++;
>       }
> Но и это не работает. Что не правильно ?
Как я говорил под postgre не програмирую - но может тебе поможет 
мой кусок кода (проверенно работает на Mysql) выводящий таблицу 
из результата запроса:

<?php function print_history($type="short", $start="yesterday", 
$end="yesterday")
    {
       $start=strftime("%Y-%m-%d", strtotime($start));
       $end=strftime("%Y-%m-%d", strtotime($end));?>

       <table width=100% cellspacing=2 cellpadding=2>
          <caption>История счетчиков<br>(<?php print 
get_update_datetime('history'); ?>)
          <thead><tr>
             <th class="cur" width=10%>Дата
             <th class="cur" width=60%>Цепочка
             <th class="cur">Байты

          <?php /* Выполним SQL запрос */
          if ($type == 'short') {
             $sql = "
             SELECT
                history.date AS date,
                chains.chain_note AS note,
                history.bytes AS bytes
             FROM history INNER JOIN chains ON 
history.chain_id=chains.chain_id
             WHERE
                (date BETWEEN '$start' AND '$end') AND
                (history.chain_id IN (0,4,5))
             ORDER BY
                date DESC,
                history.chain_id";
          }
          else {
             $sql = "
             SELECT
                history.date AS date,
                chains.chain_note AS note,
                history.bytes AS bytes
             FROM history INNER JOIN chains ON 
history.chain_id=chains.chain_id
             WHERE
                date BETWEEN '$start' AND '$end'
				 ORDER BY
                date DESC,
                history.chain_id";
          }

             $result = mysql_query($sql) or die ("Query failed: 
".mysql_error());
             $day=0;

             /* выводим resultset */
             while ($line = mysql_fetch_array($result, 
MYSQL_ASSOC)) {?>
                <tr>
                <?php if ($day == $line['date']) {?>
                   <td>
                <?php }
                else
                {?>
                   <td class="cur">
                   <?php printf ("\t%s\n", 
strftime("%d.%m.%Y",strtotime($line['date'])));
                } ?>
                   <td class="cur">
                   <?php printf ("\t%s\n", $line['note']);?>
                   <td class="cur" align=right>
                   <?php printf ("\t%s\n", 
number_format($line["bytes"],0,'.',' '));
                   $day=$line['date'];
             }

             mysql_free_result($result);
             ?>
             </table><?php
    }?>


> 
> 
>> А вообще посмотри доки к php - их есть и даже на русском  и там все 
>> довольно прозрачно - просто у меня нет Postgres - у меня mysql - так 
>> что конкретикой помочь не смогу       
> 
> Доки в основном на английском, а те что на русском, поверхностны.
Читай на английском... их много и по теме 8-)

> (Читал на www.php.net/manual/ru...)
Полезная весчь... прада там больш еполовины по англицки

> Собираюсь приобрести книгу о PHP, видел на www.books.ru две:
Имхо трата денег впустую...
В печатных книгаз нет столь полезной вещи как контекстный 
поиск... ;-)
Переводам в таких вещах я вообще пересал доверять уже года два 
назад...

У вас вообще хоть какой-т озапрос выводит? может у вас ошибка в 
запросе? У меня были ситуации когда выводилась пустая талица 
именоо из-за неправильно составленного запроса.

-- 
Всего наилучшего,
Системный Администратор ЗАО "ИК "РИКОМ-ТРАСТ"
Алексей Морсов
http://www.ricom.ru
http://www.fondmarket.ru


  parent reply	other threads:[~2004-05-26  6:44 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-05-24  5:24 Shushenskoe USZN
2004-05-24  6:41 ` Alexey Morsov
2004-05-25  3:35   ` Shushenskoe USZN
2004-05-25  4:10     ` StDog
2004-05-25  4:14     ` StDog
2004-05-25  4:51     ` crux
2004-05-25  6:03       ` Shushenskoe USZN
2004-05-26  6:44     ` Alexey Morsov [this message]
2004-05-27  6:37       ` Shushenskoe USZN
2004-05-27  7:18         ` Alexey Morsov
2004-05-28  3:17           ` Shushenskoe USZN
2004-05-28  6:07             ` Alexey Morsov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=40B43CB2.4010409@ricom.ru \
    --to=samurai@ricom.ru \
    --cc=community@altlinux.ru \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

ALT Linux Community general discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://lore.altlinux.org/community/0 community/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 community community/ http://lore.altlinux.org/community \
		mandrake-russian@linuxteam.iplabs.ru community@lists.altlinux.org community@lists.altlinux.ru community@lists.altlinux.com
	public-inbox-index community

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://lore.altlinux.org/org.altlinux.lists.community


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git