<? include_once("header.php"); ?>

    <? include_once("left.php"); ?>
    
    <!-- data changed right -->
    <div class="datasite">
        
        <!-- path -->
        <div id="breadcrumb">
            <div class="crumb">
                <ul class="breadcrumb inline">
                    <li><a title="الرئيسة" href="main.php"><?=HOME_LANG?></a></li>
                    <li><?=SEARCH_form_LANG?></a></li>
                </ul>
            </div>
        </div>
        <!-- /path -->
        
        <!-- data all here -->
        <div class="fetch_data_B">
            <?
            $keyword=$_GET['keyword'];
            //$idd=$_GET['id'];
            $selx="select * from product WHERE langu='$_SESSION[lang_g]' AND content LIKE '%$keyword%' and active=1";
            $qurx=mysql_query($selx);
            $numro=mysql_num_rows($qurx);
                                    
            if($numro){ //في حالة وجد اخبار
                                            
                                            //pagenation step 1 $each_page
                                            $each_page=8;
                                            //pagenation step 2 $post_count
                                            $qury="select * from product WHERE langu='$_SESSION[lang_g]' AND content LIKE '%$keyword%' and active=1";
                                            $resul=mysql_query($qury);
                                            $post_count=mysql_num_rows($resul);
                                            //pagenation step 3 $page_count
                                            $page_count=ceil($post_count/$each_page);
                                            //pagenation step 4 $page
                                            if(!isset($_GET['page']) || intval($_GET['page']) <=0){
                                                $page=1;
                                            }elseif($_GET['page'] > $page_count){
                                                $page=$page_count;
                                            }else{
                                                $page=$_GET['page'];
                                            }
                                            //pagenation step 5 $start
                                            if($post_count >0){
                                                $start=$each_page*($page-1);
                                            }
                                            
                                            //pagenation step 6 fetch data from db
                                            
                                            $sel="select * from product WHERE langu='$_SESSION[lang_g]' AND content LIKE '%$keyword%' and active=1 ORDER BY id DESC limit $each_page OFFSET $start";
                                            $qur=mysql_query($sel);
                                            while($result=mysql_fetch_array($qur)){
                                                extract($result);
                                                                      
                                                                           
                                                                         
                                                                  echo "<div class='plock_news'>";
																	echo "
																			<a href='products_in.php?id=$id&id_cat=$id_cat' target='_blank'>
																				
																				<span class='titel_news2'>$name</span>
																				<br />
																				<span class='intro_news'>$intro</span>
																				
																			</a>
																		";
																echo "</div>";       
                                                                         
                                                                         
                                                                            
																		
																			
                                            }
                                            
                                            //pagenation step 7 design button counter
                                            echo "<div class='counter'>";
                                                if($page_count > 1){
                                                                $first = 1;
                                                                $prev = $page - 1;
                                                                $next = $page + 1;
                                                                $last = $page_count;
                                                                
                                                                //show first & prev
                                                                if($page > 1){
                                                                    echo ' <a href="results_txt.php?keyword='.$keyword.''.$idd.'&page='.$first.'">الأول</a> ';
                                                                    echo ' <a href="results_txt.php?keyword='.$keyword.''.$idd.'&page='.$prev.'">السابق</a> ';
                                                                }
                                                                
                                                                // show numbers pages
                                                                for($i=1; $i<=$page_count; $i++){
                                                                    if($page != $i){
                                                                        echo ' <a href="results_txt.php?keyword='.$keyword.''.$idd.'&page='.$i.'">'.$i.'</a> ';
                                                                    }else{
                                                                        echo '<b>'.$i.'</b>';
                                                                    }
                                                                    
                                                                }
                                        
                                                                //show next & last
                                                                if($page < $page_count){
                                                                    echo ' <a href="results_txt.php?keyword='.$keyword.''.$idd.'&page='.$next.'">التالي</a> ';
                                                                    echo ' <a href="results_txt.php?keyword='.$keyword.''.$idd.'&page='.$last.'">الأخير</a> ';
                                                                }
                                                                
                                                }
                                            echo "</div>";
           	?>
            
            <?}else{//في حالة لم يجد?>
                        
                        <div class="marg20 dirr">
                            <?=THERE_SEARCH_form_LANG?>
                        </div>
                        
            <?}
            ?>
        </div>
        <!-- /data all here -->
        
    </div>   
    <!-- /data changed right --> 
    
<? include_once("footer.php"); ?>