function Unit2Show($sender, $params) { //устанавливаем соединение $this->Database1->Open(); //устанавливаем кодировку запросов $sql="SET NAMES cp1251"; $this->Query1->SQL=$sql; $this->Query1->LimitStart='-1'; $this->Query1->LimitCount='-1'; $this->Query1->Open(); $this->Query1->Close(); //выполняем запрос $sql="select name, um, quantity, cost from `test`.`goods`"; $this->Query1->SQL=$sql; $this->Query1->LimitStart='0'; $this->Query1->LimitCount='10'; $this->Query1->Open(); //количество записей должно быть больше нуля if ($this->Query1->readRecordCount()>0) { //отображаем заголовок таблицы echo "<br>"; echo '<font size=3>База данных</font>'; echo "<br>"; echo "<br>"; echo "<table cellspacing=0 cellpadding=1 border=1 width=90% align=left>"; //отображаем названия полей echo "<tr>"; echo "<th align=center> <font size=2>Наименование</font></th>"; echo "<th align=center> <font size=2>Единица измерения</font></th>"; echo "<th align=center> <font size=2>Количество</font></th>"; echo "<th align=center> <font size=2>Цена</font></th>"; echo "</tr>"; //в цикле выводим записи из результата запроса $this->Query1->First(); while (!$this->Query1->EOF) { echo "<tr>"; echo "<td>" . $this->Query1->name . "</td>"; echo "<td>" . $this->Query1->um . "</td>"; echo "<td>" . $this->Query1->quantity . "</td>"; echo "<td>" . $this->Query1->cost . "</td>"; echo "</tr>"; $this->Query1->Next(); } echo '</table>'; } $this->Query1->Close(); //закрываем соединение $this->Database1->Close(); } |