<?php require_once('./Connections/BE2.php'); ?>
<?

$currentPage = "showfrend.html";//$_SERVER["PHP_SELF"];  
 
$maxRows_Rt2 = 5000;
$pageNum_Rt2 = 0;
if (isset($_GET['pageNum_Rt2'])) {
  $pageNum_Rt2 = $_GET['pageNum_Rt2'];
}
$startRow_Rt2 = $pageNum_Rt2 * $maxRows_Rt2; 
  
mysql_select_db($database_BE2, $BE2);
 
$dday=date('Y-m-d');
$query_Rt2 = "SELECT * FROM usertree WHERE 1 ORDER BY id " ;
$Rt2 = mysql_query($query_Rt2, $BE2) or die(mysql_error());
$query_limit_Rt2 = sprintf("%s LIMIT %d, %d", $query_Rt2, $startRow_Rt2, $maxRows_Rt2);
$Rt2 = mysql_query($query_limit_Rt2, $BE2) or die(mysql_error());
$row_Rt2 = mysql_fetch_assoc($Rt2);


if (isset($_GET['totalRows_Rt2'])) {
  $totalRows_Rt2 = $_GET['totalRows_Rt2'];
} else {
  $all_Rt2 = mysql_query($query_Rt2);
  $totalRows_Rt2 = mysql_num_rows($all_Rt2);
}
$totalPages_Rt2 = ceil($totalRows_Rt2/$maxRows_Rt2)-1;

$queryString_Rt2 = "";
if (!empty($_SERVER['QUERY_STRING'])) {
  $params = explode("&", $_SERVER['QUERY_STRING']);
  $newParams = array();
  foreach ($params as $param) {
    if (stristr($param, "pageNum_Rt2") == false && 
	    stristr($param, "menu") == false && 
        stristr($param, "totalRows_Rt2") == false) {
      array_push($newParams, $param);
    }
  }
  if (count($newParams) != 0) {
    $queryString_Rt2 = "&" . htmlentities(implode("&", $newParams));
  }
}
$queryString_Rt2 = sprintf("&totalRows_Rt2=%d%s", $totalRows_Rt2, $queryString_Rt2); 
 
?>
<style type="text/css">
 
  .scrollme {
    overflow-x: auto;
  }
</style>   
 

   <? if($totalRows_Rt2>0){ ?>
 
  <div class="container">
        
                  <!-- Products Block --> 
                
                
                  <? /* 自然序號	代號	完成	1線3加盟
				  <div class="col-md-12" style="overflow-x: auto">			2線9加盟	
				  min-width:450px;
				   <tbody style="overflow-y: scroll; overflow-x: hidden; height: 100px;">
				    //<div class="g-overflow-x-scroll g-overflow-x-visible-md">
					table table-bordered table-striped table-condensed table-hover
				  */ ?>
 <div class="scrollme">                        

  <table class="table table-responsive" >
  <thead>
  <tr>
    <th width="36" align="center" nowrap="nowrap">序號</th>
    <th width="41" align="center" nowrap="nowrap">代號 </th>
    <th width="36" align="center" nowrap="nowrap">完成</th>
    <th colspan="3" align="center">推薦3位加盟 </th>
    <th colspan="9" align="center">分享9位加盟</th>
    </tr>
    </thead>
    <?  do {   ?>
    <tbody>
  <tr>
    <td align="center"><?=$row_Rt2['id'] ?></td>
    <td align="center"><?=$row_Rt2['name'] ?></td>
    <td align="center"><?=$row_Rt2['fck'] ?></td>
    <td width="38" align="center"><?=$row_Rt2['f1'] ?></td>
    <td width="13" align="center"><?=$row_Rt2['f2'] ?></td>
    <td width="14" align="center"><?=$row_Rt2['f3'] ?></td>
    <td width="1" align="center"><?=$row_Rt2['f4'] ?></td>
    <td width="4" align="center"><?=$row_Rt2['f5'] ?></td>
    <td width="4" align="center"><?=$row_Rt2['f6'] ?></td>
    <td width="4" align="center"><?=$row_Rt2['f7'] ?></td>
    <td width="4" align="center"><?=$row_Rt2['f8'] ?></td>
    <td width="4" align="center"><?=$row_Rt2['f9'] ?></td>
    <td width="4" align="center"><?=$row_Rt2['f10'] ?></td>
    <td width="4" align="center"><?=$row_Rt2['f11'] ?></td>
    <td width="4" align="center"><?=$row_Rt2['f12'] ?></td>
    </tr>
    </tbody>
   <?php } while ($row_Rt2 = mysql_fetch_assoc($Rt2)); ?> 
 
</table>
 
 </div>
             <ul class="pagination">
                    <?   
                     if( $totalPages_Rt2 >0){	 
						    //分頁程式
if($totalPages_Rt2<5){
		 $start=0;
		 $end=$totalPages_Rt2;
		}else{  
	    $start=$pageNum_Rt2-5;
		$end=$pageNum_Rt2+5;
        if ($start<0){
		 $start=0;
		 $end=10; } 
		 else { $end=$start+10 ;}
		 if ($end>$totalPages_Rt2){ 
		   $start = $end-$totalPages_Rt2-5;
		   $end=$totalPages_Rt2;
		   }
		 if ($end-$start>10){ 
		   $start = $end-10;
		   }  
		 } ?> 
                     <?php if ($pageNum_Rt2 > 0) { // Show if not first page ?>
                     <li><a href="<?php printf("%s?pageNum_Rt2=%d%s", $currentPage, max(0, $pageNum_Rt2 - 1), $queryString_Rt2); ?>">上一頁</a></li><?php } // Show if not first page ?>
                    	<?	   
		for($i=$start;$i<=$end;$i++){
		if($i==$pageNum_Rt2){ echo '<li class="active"><a href="#">'.($i+1).'</a></li>';} else {?>
            <li><a href="<?php printf("%s?pageNum_Rt2=%d%s", $currentPage, min($totalPages_Rt2, $i), $queryString_Rt2); ?>"><? echo $i+1 ;?></a></li>
                 
                        <?	}   }  ?>

                      <?php if ($pageNum_Rt2 < $totalPages_Rt2) { // Show if not last page ?>
            <li><a href="<?php printf("%s?pageNum_Rt2=%d%s", $currentPage, min($totalPages_Rt2, $pageNum_Rt2 + 1), $queryString_Rt2); ?>">下一頁</a></li>
                        <?php }  
						             } ?>
								
						 </ul>
 
  
 
  </div>	
 
   <? } ?>     
  
     
<?php
mysql_free_result($Rt2);
?>        
        