<? ob_start();
session_start();
require_once("../dbconnect.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<?php include_once("title.php");?>
<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}
-->
</style>

<link href="stylesheet.css" rel="stylesheet" type="text/css" />
<link href="../pagecss.css" rel="stylesheet" type="text/css" />
<script language="javascript" src="ajaxvalid.js"></script>
<style type="text/css">
<!--
.style2 {
	color: #21262A;
	font-size: 12px;
}
-->
</style>
</head>
<body>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td valign="top"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
            <td><? require_once("header.php"); ?></td>
          </tr>
          <tr>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
              <tr>
                <td><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
                  <tr>
                    <td height="30" class="cate_pro">Best Customer Orders-Total</td>
                    <td>&nbsp;</td>
                    <td class="index_text" align="right">&nbsp;</td>
                    <td width="20">&nbsp;</td>
                  </tr>
                </table></td>
              </tr>
              <tr>
                <td>&nbsp;</td>
              </tr>
              <tr>
                <td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td width="72%" valign="top" style="padding-right:1px;"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                      <tr>
                        <td height="35" colspan="5"><table border="0" cellpadding="2" cellspacing="0" width="100%">
                          <tr class="dataTableHeadingRow">
                            <td width="92" height="20" align="center" bgcolor="#D7D6CC" class="dataTableHeadingContent"><u>Id#</u></td>
                            <td width="255" align="left" bgcolor="#D7D6CC" class="dataTableHeadingContent"><strong>Customers</strong></td>
                            <td width="62" align="left" bgcolor="#D7D6CC" class="dataTableHeadingContent">&nbsp;</td>
                            <td width="1" align="right" bgcolor="#D7D6CC" class="dataTableHeadingContent">&nbsp;</td>
                            <td width="1" align="right" bgcolor="#D7D6CC" class="dataTableHeadingContent">&nbsp;</td>
                            <td width="11" align="left" bgcolor="#D7D6CC" class="dataTableHeadingContent">&nbsp;</td>
                            <td width="42" align="left" bgcolor="#D7D6CC" class="dataTableHeadingContent">&nbsp;</td>
                            <td width="163" align="left" bgcolor="#D7D6CC" class="dataTableHeadingContent"><strong>Purchased  </strong>&nbsp;</td>
                            <td width="13" align="center" bgcolor="#D7D6CC" class="dataTableHeadingContent">&nbsp;</td>
                            <td width="49" align="left" bgcolor="#D7D6CC" class="dataTableHeadingContent">&nbsp;</td>
                          </tr>
 <?php /*?>     <? 
		$sql = "Select a.*,b.* from register a,tblcart b where a.user_id=b.USERID and b.status=2 order by b.CARTID desc";
	    $catres = mysql_query($sql); 
	         while($catrow=mysql_fetch_array($catres))
			 { 
		?><?php */?>
		
		
		  <?php
			
				//$tbl_name="products";		//your table name
	// How many adjacent pages should be shown on each side?
	$adjacents = 2;
	
	/* 
	   First get total number of rows in data table. 
	   If you have a WHERE clause in your query, make sure you mirror it here.
	*/
	$query = "Select a.*,b.* from register a,tblcart b where a.user_id=b.USERID and b.status=2";
      $zing = mysql_num_rows(mysql_query($query));
	 $total_pages = $zing;
	
	/* Setup vars for query. */
	$targetpage = "customerorder.php"; 	//your file name  (the name of this file)
	$limit =16; 								//how many items to show per page
	$page = $_GET['page'];
	if($page) 
		$start = ($page - 1) * $limit; 			//first item to display on this page
	else
		$start = 0;								//if no page var is given, set start to 0
	
	/* Get data. */
$sql = "Select a.*,b.* from register a,tblcart b where a.user_id=b.USERID and b.status=2 order by b.CARTID desc  LIMIT $start, $limit";
	$catres = mysql_query($sql);
	
	/* Setup page vars for display. */
	if ($page == 0) $page = 1;					//if no page var is given, default to 1.
	$prev = $page - 1;							//previous page is page - 1
	$next = $page + 1;							//next page is page + 1
	$lastpage = ceil($total_pages/$limit);		//lastpage is = total pages / items per page, rounded up.
	$lpm1 = $lastpage - 1;						//last page minus 1
	
	/* 
		Now we apply our rules and draw the pagination object. 
		We're actually saving the code to a variable in case we want to draw it more than once.
	*/
	$pagination = "";
	if($lastpage > 1)
	{	
		$pagination .= "<div class=\"pagination\">";
		//previous button
		if ($page > 1) 
			$pagination.= "<a href=\"$targetpage?page=$prev\">« previous</a>";
		else
			$pagination.= "<span class=\"disabled\">« previous</span>";	
		
		//pages	
		if ($lastpage < 7 + ($adjacents * 2))	//not enough pages to bother breaking it up
		{	
			for ($counter = 1; $counter <= $lastpage; $counter++)
			{
				if ($counter == $page)
					$pagination.= "<span class=\"current\">$counter</span>";
				else
					$pagination.= "<a href=\"$targetpage?page=$counter\">$counter</a>";					
			}
		}
		elseif($lastpage > 5 + ($adjacents * 2))	//enough pages to hide some
		{
			//close to beginning; only hide later pages
			if($page < 1 + ($adjacents * 2))		
			{
				for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++)
				{
					if ($counter == $page)
						$pagination.= "<span class=\"current\">$counter</span>";
					else
						$pagination.= "<a href=\"$targetpage?page=$counter\">$counter</a>";					
				}
				$pagination.= "...";
				$pagination.= "<a href=\"$targetpage?page=$lpm1\">$lpm1</a>";
				$pagination.= "<a href=\"$targetpage?page=$lastpage\">$lastpage</a>";		
			}
			//in middle; hide some front and some back
			elseif($lastpage - ($adjacents * 2) > $page && $page > ($adjacents * 2))
			{
				$pagination.= "<a href=\"$targetpage?page=1\">1</a>";
				$pagination.= "<a href=\"$targetpage?page=2\">2</a>";
				$pagination.= "...";
				for ($counter = $page - $adjacents; $counter <= $page + $adjacents; $counter++)
				{
					if ($counter == $page)
						$pagination.= "<span class=\"current\">$counter</span>";
					else
						$pagination.= "<a href=\"$targetpage?page=$counter\">$counter</a>";					
				}
				$pagination.= "...";
				$pagination.= "<a href=\"$targetpage?page=$lpm1\">$lpm1</a>";
				$pagination.= "<a href=\"$targetpage?page=$lastpage\">$lastpage</a>";		
			}
			//close to end; only hide early pages
			else
			{
				$pagination.= "<a href=\"$targetpage?page=1\">1</a>";
				$pagination.= "<a href=\"$targetpage?page=2\">2</a>";
				$pagination.= "...";
				for ($counter = $lastpage - (2 + ($adjacents * 2)); $counter <= $lastpage; $counter++)
				{
					if ($counter == $page)
						$pagination.= "<span class=\"current\">$counter</span>";
					else
						$pagination.= "<a href=\"$targetpage?page=$counter\">$counter</a>";					
				}
			}
		}
		
		//next button
		if ($page < $counter - 1) 
			$pagination.= "<a href=\"$targetpage?page=$next\">next »</a>";
		else
			$pagination.= "<span class=\"disabled\">next »</span>";
		$pagination.= "</div>\n";		

	}
?>
		<? 
						/*	$sql = "Select user_id,Fname,Lname,Email,Phone,Fax,Password,date_format(regdate,'%D %M %y') from register";
	$catres = mysql_query($sql); 
	$laxman=0;*/
	 while($catrow=mysql_fetch_array($catres))
	 { 
	//$laxman++; 
						  ?>
		
		
		
		
		
		
		
		
                         <div id="stufftotoggle">
                          <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)">
                            <td width="92" height="30" align="center" class="dataTableContent"><?php echo $catrow['CARTID']; ?></td>
                            <td align="left" class="dataTableContent">
							<?php echo $catrow['Fname']."&nbsp;".$catrow['Lname']; ?></td>
                            <td align="left" class="dataTableContent">&nbsp;</td>
                            <td colspan="2" class="dataTableContent" align="left">&nbsp;</td>
                            <td class="dataTableContent" align="left">&nbsp;</td>
                            <td class="dataTableContent" align="left">&nbsp;</td>
                            <td class="dataTableContent" align="left"><?php echo $catrow['GRANDTOTAL']; ?>&nbsp;</td>
                            <td class="dataTableContent" align="center">&nbsp;</td>
                            <td class="dataTableContent" align="center">&nbsp;</td>
                          </tr>
                          </div>
                          <? } ?>
                        </table></td>
                      </tr>
                      <tr>
                        <td height="35" colspan="5" align="center"><?=$pagination?> </td>
                        </tr>
					  
					     <tr>
                        <td width="22%" height="35">&nbsp;</td>
                        <td width="16%" align="center"><a href="addcategory.php?addcat=addcat"></a></td>
                        <td width="16%" align="center"></td>
                        <td width="23%">&nbsp;</td>
                        <td width="23%">&nbsp;             </td>
                      </tr>
					  
                    </table></td>
                    <td width="28%" valign="top">&nbsp;</td>
                  </tr>
                </table></td>
              </tr>
              <tr>
                <td>&nbsp;</td>
              </tr>
            </table></td>
          </tr>
          <tr>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td><? require_once("footer.php"); ?></td>
          </tr>
          <tr>
            <td>&nbsp;</td>
          </tr>
        </table></td>
      </tr>
    </table></td>
  </tr>
</table>
</body>
</html>
