<?php
$PATH = $_SERVER['DOCUMENT_ROOT'].'/';
include_once($PATH.'include/config.html');
$search = $_POST['search'];
$bookid = $_POST['bookid'];
function getYearIssue($id){
    $sql="SELECT issue,year,text_issue FROM emagazine WHERE id='".$id."'";
    $query = mysql_query($sql);
    $res = mysql_fetch_array($query);
    mysql_free_result($query);

	$data_arr = split('<br',$res['issue']);
return $data_arr[0];
    #return 'ปี '.$res['year'].' '.$res['text_issue'];
}
if (isset($search) && isset($bookid)) {

$sql ="SELECT id,book_id,page_title,page_num,source_file,page_description,cover_page FROM page_emagazine ";
$sql.=" WHERE page_tag LIKE '%,".$search.",%' AND book_id='".$bookid."' AND status =1 ";
$query = mysql_query($sql) or die(mysql_error());

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns:csi="http://www.massimocorner.com/libraries/csi/" lang="en">

<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width; initial-scale=1.0;" />
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<title>IPST สถาบันส่งเสริมการสอนวิทยาศาสตร์และเทคโนโลยี</title>
	<!--Loading the main style sheet-->
    <?php 
    include 'css-include.html'; 
    ?>
	<link href="../../css/search.css" rel="stylesheet" type="text/css" />
</head>

<body>
	<?php 
    include 'nav-bar.html'; 
    ?>
	<!-- <div class="nav-bar">
	<div class="nav-bar-container">

        <div class="logo2f">
   	    	<img src="../../image/logo.png" width="288" height="50">
        </div>
        <div class="search-bar">
            <form method="post" action="search_result.html">
            <input name="search" type="input" />
            <input name="bookid" value="52" type="hidden" />
            </form>
        </div>
	</div>
</div> -->

	  <div class="logoleft2f">
    		<img src="../../image/logoleft.png" width="180" height="197" />
      </div>

	  <div class="dossier-search">
			<div id="sc_search">
            	<ul>
                    <?php while ($res = mysql_fetch_array($query)) {?>
                        
                	<li>
                    	<div class="img-search">	
       	    		    	<img src="http://emagazine.ipst.ac.th/<?php echo $res['cover_page'];?>" width="68" height="90" /> 
                        </div>
                        <div class="detail-search">
                            <!--<div class="title_year"></div>-->
                        	<div class="page-search"><?php echo getYearIssue($res['book_id']);?> หน้าที่ <?php echo $res['page_num'];?></div>
                        	<h4><a href="http://emagazine.ipst.ac.th/<?php echo $res['source_file'];?>"><?php echo $res['page_title'];?></a></h4>
                        	<a class="link-search" href="http://emagazine.ipst.ac.th/<?php echo $res['source_file'];?>">http://emagazine.ipst.ac.th/<?php echo $res['source_file'];?></a>
                        	<p class="detail"><?php echo $res['page_description'];?></p>
                        </div>
                    </li>
                    <?php }?>
                
                    
                </ul>
		  </div>
		</div><!-- Div dossier-start-bg-->
	</div><!--Div hyphenate-->

</body>
</html>
<?php }?>