Warning: Cannot use a scalar value as an array in /home/admin/public_html/forum/include/fm.class.php on line 757

Warning: Invalid argument supplied for foreach() in /home/admin/public_html/forum/include/fm.class.php on line 770

Warning: Invalid argument supplied for foreach() in /home/admin/public_html/forum/topic.php on line 737
Форумы портала PHP.SU :: Нужна помощ

 PHP.SU

Программирование на PHP, MySQL и другие веб-технологии
PHP.SU Портал     На главную страницу форума Главная     Помощь Помощь     Поиск Поиск     Поиск Яндекс Поиск Яндекс     Вакансии  Пользователи Пользователи


 Страниц (1): [1]   

> Описание: Нужна помощ
sewer
Отправлено: 03 Мая, 2012 - 09:50:04
Post Id


Новичок


Покинул форум
Сообщений всего: 2
Дата рег-ции: Май 2012  


Помог: 0 раз(а)




блок отвечает за пролистування страниц статей
При нажатии на новую страницу ( 2,3,4,) Дублируется список страниц и оглавление
Какие тут могут быть ошибки

PHP:
скопировать код в буфер обмена
  1.  
  2.  
  3. unction BookChapter() {
  4.   if (isset($this->param['uid'])) {
  5.     $sql = 'select bc.name, bc.book_id, bc.id, b.is_short from '.$this->db_pref.'book_chapter bc, '.$this->db_pref.'book_title b where b.id = bc.book_id and uid='.intval($this->param['uid']);
  6.     $this->DB->query('update '.$this->db_pref.'book_chapter set cnt=cnt+1 where uid='.intval($this->param['uid']));
  7.   } else {
  8.     $sql = 'select name, id, book_id from '.$this->db_pref.'book_chapter where '.
  9.     'book_id='.intval($this->param['book_id']).' and id='.intval($this->param['chapter_id']);
  10.     $this->DB->query('update '.$this->db_pref.'book_chapter set cnt=cnt+1 where '.
  11.     'book_id='.intval($this->param['book_id']).' and id='.intval($this->param['chapter_id']));
  12.   }
  13.   //die($sql);
  14.    $spam = $this->DB->select($sql);
  15.   if ($spam[0]['is_short']==1) {
  16.     $this->param['id'] = $spam[0]['book_id'];
  17.     $out = '<style>li { display: inline;}</style>' . $this->BookItem();
  18.   } else $out = '';
  19.   $this->param['book_id'] = $spam[0]['book_id'];
  20.   $this->param['chapter_id'] = $spam[0]['id'];
  21.   $book = $this->DB->select('select ufu from '.$this->db_pref.'book_title where id='.intval($this->param['book_id']));
  22.   $out .= '<h5>'.$spam[0]['name'].'</h1>'.
  23.   '<p><a href="/'.($this->is_short==$this->page_id?'articles':'books').'/'.$book[0]['ufu'].'">Back</a></p>'.
  24.   file_get_contents('../images/book/'.intval($this->param['book_id']).'/'.intval($this->param['chapter_id']).'.html');
  25.   if ($this->is_short == $this->page_id) {
  26.     $this->param['id'] = $this->param['book_id'];
  27.     $out = $this->BookItem().$out;
  28.   }  
  29.   return $out;
  30. }
  31.  
  32. function BookItem() {
  33.   $this->DB->query('update '.$this->db_pref.'book_title set cnt=cnt+1 where id='.intval($this->param['id']));
  34.   $book = $this->DB->select('select * from '.$this->db_pref.'book_title where id = '.intval($this->param['id']));
  35.   /*if ($book[0]['is_short']==1) {
  36.     $spam = $this->DB->select('select ufu from '.$this->db_pref.'book_chapter where book_id = '.intval($this->param['id']).' order by id limit 1');
  37.     header('Location: /books/'.$spam[0]['ufu']);
  38.   }*/
  39.   $this->smarty->assign('book_name', $book[0]['name']);
  40.   $this->smarty->assign('book_cnt', $book[0]['cnt']);
  41.   $this->smarty->assign('book_ufu', $book[0]['ufu']);
  42.  
  43.   $sql = 'select * from '.$this->db_pref.'book_chapter where book_id = '.
  44.   intval($this->param['id']).' order by id';
  45.   $spam = $this->DB->select($sql);
  46.   for ($i=0, $j=count($spam); $i<$j; $i++) {
  47.     $this->smarty->append($spam[$i]);
  48.   }
  49.   return $this->smarty->fetch('book_'.($this->is_short==$this->page_id?'article':$this->tmpl).'_item.html');
  50. }
  51.  
  52. function BookList1() {
  53.   $sql = 'select a.name as aname, b.id as bid, b.name as bname, b.cnt, b.ufu, b.is_short, (select ufu from '.$this->db_pref.'book_chapter bc where b.id=bc.book_id order by bc.id limit 1) as cufu from '.
  54.   $this->db_pref.'book_title b, '.$this->db_pref.'book_author a '.
  55.   'where a.id = b.author_id '.
  56.   (isset($this->param['category_id'])?'and b.category_id='.intval($this->param['category_id']).' ':'').
  57.   ($this->is_short==$this->page_id?'and is_short=1 ':' and (is_short=0 or is_short is null)').
  58.   'order by cnt desc'.
  59.   ($this->limit>0?' limit '.$this->limit:'');
  60.  
  61.   $spam = $this->DB->select($sql);
  62.   for ($i=0, $j=count($spam); $i<$j; $i++) {
  63.     //if ($spam[$i]['is_short']==1) $spam[$i]['ufu'] = $spam[$i]['cufu'];
  64.     $spam[$i]['cnt'] = intval($spam[$i]['cnt']);
  65.     $this->smarty->append($spam[$i]);
  66.   }
  67.   $this->smarty->assign('is_short', ($this->is_short-$this->page_id));
  68.   return $this->smarty->fetch('book_'.$this->tmpl.'_list.html');
  69. }
  70.  
  71. function BookList() {
  72.   $sql = 'select a.name as aname, b.id as bid, b.name as bname, b.cnt, b.ufu from '.
  73.   $this->db_pref.'book_title b, '.$this->db_pref.'book_author a '.
  74.   'where a.id = b.author_id '.
  75.   (isset($this->param['category_id'])?'and b.category_id='.intval($this->param['category_id']).' ':'').
  76.   ($this->is_short==$this->page_id?'and is_short=1 ':' and (is_short=0 or is_short is null)').
  77.   'order by cnt desc'.
  78.   ($this->limit>0?' limit '.$this->limit:'');
  79.  
  80.   $spam = $this->DB->select($sql);
  81.   for ($i=0, $j=count($spam); $i<$j; $i++) {
  82.     $spam[$i]['cnt'] = intval($spam[$i]['cnt']);
  83.     $this->smarty->append($spam[$i]);
  84.   }
  85.   $this->smarty->assign('is_short', ($this->is_short-$this->page_id));
  86.   $out = $this->smarty->fetch('book_'.$this->tmpl.'_list.html');
  87.  
  88.   if ($this->is_short!=$this->page_id) {
  89.     $smarty = new Smarty();
  90.     $smarty->compile_check = true;
  91.  
  92.     $sql = 'select a.name as aname, b.id as bid, b.name as bname, b.cnt, b.ufu from '.
  93.     $this->db_pref.'book_title b, '.$this->db_pref.'book_author a '.
  94.     'where a.id = b.author_id '.
  95.     (isset($this->param['category_id'])?'and b.category_id='.intval($this->param['category_id']).' ':'').
  96.     ('and is_short=1 ').
  97.     'order by cnt desc'.
  98.     ($this->limit>0?' limit '.$this->limit:'');
  99.     $spam = $this->DB->select($sql);
  100.     for ($i=0, $j=count($spam); $i<$j; $i++) {
  101.       $spam[$i]['cnt'] = intval($spam[$i]['cnt']);
  102.       $smarty->append($spam[$i]);
  103.     }
  104.     $smarty->assign('is_short', 0);
  105.     $smarty->assign('dont_head', 1);
  106.     $out .= $smarty->fetch('book_'.$this->tmpl.'_short.html');
  107.   }
  108.  
  109.   return $out;
  110. }
  111.  
  112.  
 
 Top
Страниц (1): [1]
Сейчас эту тему просматривают: 0 (гостей: 0, зарегистрированных: 0)
« CMS и фреймворки »


Все гости форума могут просматривать этот раздел.
Только зарегистрированные пользователи могут создавать новые темы в этом разделе.
Только зарегистрированные пользователи могут отвечать на сообщения в этом разделе.
 



Powered by PHP  Powered By MySQL  Powered by Nginx  Valid CSS  RSS

 
Powered by ExBB FM 1.0 RC1. InvisionExBB