<?php
require '../Run.php';
require '../include/page.inc.php';
$mysql = new D('dd_book_name');
$bookname = $mysql->where(array('bookid'=>$_GET['id'],'gro'=>$_GET['cid'],'siteid'=>WAPID))
	->find();
	if(!$bookname){
		ehtml("本书不存在哦!可能是链接错误或者资源已经被删除了!");
		exit();
	}
$mysql2 = new D('dd_book_content');
$bookcontent = $mysql2->where(array('groid'=>$bookname['bookid'],'siteid'=>WAPID))
					->limit(slist($_GET['p'],20),20)
					->select();
					$olt = '[已完结]';
				if($bookname['ol'] == '1')
				{
					$olt = '[连载中]';
				}
		echo head($bookname['title']);
		echo topNav('章节选择','<a href="list.php?cid='.$_GET['cid'].'">列表</a>','<a href="../index.php">首页</a>');
		echo '<div class="title">图书简介</div>';
		echo '<div class="content">';
		echo $bookname['content'];
		echo '</div>';
		echo '<div class="title">本书章节'.$olt.'</div>';
		if($bookcontent){
			$num = 0;
			foreach($bookcontent as $value)
			{	
				$div = $num++%2 == 0?'line1':'line2';
				echo '<div class="'.$div.'"><a href="read.php?cid='.$bookname['gro'].'&id='.$bookname['bookid'].'&rid='.$value['bookid'].'">'.$value['title'].'</a></div>';
			}
		
		}
	$backnums = $mysql2->where(array('groid'=>$bookname['bookid'],'siteid'=>WAPID))
		->select();
	$url = 'content.php?cid='.$_GET['cid'].'&';
	echo page(count($backnums),20,$url,NULL,'view');
	echo footer(1);