| class pg{ |
| private $myConect; |
| private $total; |
| private $page; |
| private $postrow=array(); |
| private $result; |
| public $num; |
| public $posts; |
| private $dir; |
| private $Url; |
| private $avatar; |
| private $linkId; |
| private $av; |
| |
| |
| function setPage($conect,$param,$param2,$urlPage){ |
| $this->Url=$urlPage; |
| $this->myConect=$conect; |
| $this->result=$result; |
| //$this->sql=$param; |
| $this->num = 5; |
| // Извлекаем из URL текущую страницу |
| $this->page = $_GET['page']; |
| // Определяем общее число сообщений в базе данных |
| //$this->result = mysql_query($param,$this->myConect); |
| //$this->posts = mysql_result($this->result, 0); |
| // Находим общее число страниц |
| $this->total = intval(($param - 1) / $this->num) + 1; |
| // Определяем начало сообщений для текущей страницы |
| $this->page = intval($this->page ); |
| // Если значение $page меньше единицы или отрицательно |
| // переходим на первую страницу |
| // А если слишком большое, то переходим на последнюю |
| if(empty($this->page ) or $this->page < 0) $this->page = 1; |
| if($this->page > $this->total) $this->page = $this->total; |
| // Вычисляем начиная к какого номера |
| // следует выводить сообщения |
| $start = $this->page * $this->num - $this->num; |
| // Выбираем $num сообщений начиная с номера $start |
| $this->result = mysql_query("".$param2." LIMIT $start, ".$this->num."",$this->myConect); |
| // В цикле переносим результаты запроса в массив $postrow |
| while ( $this->postrow[] = mysql_fetch_array($this->result)); |
| } |
| |
| function getMessage(){ |
| echo "<table border='0' width='100%'>"; |
| |
| for($i = 0; $i < $this->num; $i++) |
| { |
| if($this->postrow[$i]['aid']!=0){ |
| if( $this->postrow[$i]['aid'] == '2' ) { $topic_bot = '<img src="'.DIR.'/template/img/vunderkind.gif" alt="" border="0">';} |
| elseif( $this->postrow[$i]['aid'] == '3' ) { $topic_bot = '<img src="'.DIR.'/template/img/traxtenberg.gif" alt="" border="0">';} |
| elseif( $this->postrow[$i]['aid'] == '4' ) { $topic_bot = '<img src="'.DIR.'/template/img/mazafaka.gif" alt="" border="0">';} |
| |
| [color=red] Вот тут нудно выыести Аватарку юзера[/color] |
| else { $topic_bot = ''; } |
| |
| echo "<tr> |
| <td width='7%' style='padding:2px 5px 2px 8px;border:1px solid #CCCCCC'>".$topic_bot." |
| <br/><a href=\"addto.php".$this->Url."&nocache=$nocache&uid=".$this->postrow[$i]['aid']."\">".$this->postrow[$i]['nickname']."</a> |
| <br/>".$this->postrow[$i]['time']."</td> |
| <td style='padding:2px 5px 2px 8px;border:1px solid #CCCCCC'>".$this->postrow[$i]['msg']."</td> |
| |
| </tr>"; |
| } |
| } |
| echo "</table>"; |
| } |
| function getPage(){ |
| if ($this->page != 1) $pervpage = '<a href= '.($this->Url).'&page=1><<</a> |
| <a href= '.($this->Url).'&page='. ($this->page - 1) .'><</a> '; |
| // Проверяем нужны ли стрелки вперед |
| if ($this->page != $this->total) $nextpage = ' <a href= '.($this->Url).'&page='. ($this->page + 1) .'>></a> |
| <a href= '.($this->Url).'&page=' .$this->total. '>>></a>'; |
| // Находим две ближайшие станицы с обоих краев, если они есть |
| if($this->page - 2 > 0) $page2left = ' <a href= '.($this->Url).'&page='. ($this->page - 2) .'>'. ($this->page - 2) .'</a> | '; |
| if($this->page - 1 > 0) $page1left = '<a href= '.($this->Url).'&page='. ($this->page - 1) .'>'. ($this->page - 1) .'</a> | '; |
| if($this->page + 2 <= $this->total) $page2right = ' | <a href= '.($this->Url).'&page='. ($this->page + 2) .'>'. ($this->page + 2) .'</a>'; |
| if($this->page + 1 <= $this->total) $page1right = ' | <a href= '.($this->Url).'&page='. ($this->page + 1) .'>'. ($this->page + 1) .'</a>'; |
| |
| // Вывод меню |
| return '<span style="background:#CCCCCC;padding:4px;margin:12px 10px 19px 10px"> |
| '.$pervpage.$page2left.$page1left.'<b>'.$this->page.'</b>'.$page1right.$page2right.$nextpage.'</span><br/>'; |
| |
| |
| } |
| |
| |
| } |