<? 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" />
<title>Welcome to Sir Box and Plastics</title>
<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">Featured Products</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="3"><table border="0" cellpadding="2" cellspacing="0" width="100%">
                          <tr class="dataTableHeadingRow">
                            <td width="91" height="20" align="center" bgcolor="#D7D6CC" class="dataTableHeadingContent"><u>Id#</u></td>
                            <td width="251" align="left" bgcolor="#D7D6CC" class="dataTableHeadingContent"><strong>Products</strong></td>
                            <td width="61" align="left" bgcolor="#D7D6CC" class="dataTableHeadingContent">Price</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="114" align="left" bgcolor="#D7D6CC" class="dataTableHeadingContent"><strong>Available</strong>&nbsp;&nbsp;</td>
                            <td width="88" align="left" bgcolor="#D7D6CC" class="dataTableHeadingContent"><strong>Expires</strong></td>
                            <td width="13" align="center" bgcolor="#D7D6CC" class="dataTableHeadingContent">&nbsp;</td>
                            <td width="45" align="left" bgcolor="#D7D6CC" class="dataTableHeadingContent">Action&nbsp;</td>
                          </tr>
						  
				                          
								<?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 COUNT(*) as num FROM $tbl_name where featured=1";
	$total_pages = mysql_fetch_array(mysql_query($query));
	$total_pages = $total_pages[num];
	
	/* Setup vars for query. */
	$targetpage = "viewfeatured.php"; 	//your file name  (the name of this file)
	$limit =9; 								//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 * from products where featured=1 order by pid 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 * from products where featured=1";
	//$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="91" height="30" align="center" class="dataTableContent"><?php echo $catrow['pid']; ?></td>
                            <td align="left" class="dataTableContent"><?php echo $catrow['pname']; ?></td>
                            <td align="left" class="dataTableContent"><?php echo $catrow['price']; ?></td>
                            <td colspan="2" class="dataTableContent" align="left">&nbsp;</td>
                            <td class="dataTableContent" align="left">&nbsp;</td>
                            <td class="dataTableContent" align="left"><?php echo $catrow['fsdate']; ?></td>
                            <td class="dataTableContent" align="left"><?php echo $catrow['fedate']; ?></td>
                            <td class="dataTableContent" align="center">&nbsp;</td>
                            <td class="dataTableContent" align="center">
 <?          
 if($_GET['userid']!=$catrow['pid'])
{?>
           <a href="viewfeatured.php?edit=edit&userid=<? echo $catrow['pid']; ?>&page=<?php echo $_GET['page']; ?>">
                   <img src="images/icon_info.gif" border="0" />                   </a>
                   
           <? } else
		   {?>
            <a href="viewfeatured.php?edit=edit&userid=<? echo $catrow['pid']; ?>&page=<?php echo $_GET['page']; ?>">
                            
                   <img src="images/icon_arrow_right.gif" border="0" />                   </a>
           <?
		   }?>                          </td>
                          </tr>
                          </div>
                          <? } ?>
                        </table></td>
                      </tr>
                      <tr>
                        <td height="35" align="center"><?=$pagination?></td>
                        <td width="23%">&nbsp;</td>
                        <td width="23%">
                <a href="featuredproduct.php"><img src="images/button_insert.gif" border="0"/></a>&nbsp;</td>
                      </tr>
                    </table></td>
                    <td width="28%" valign="top">
                    <? if($_GET['edit']=='edit')
				    {
				 $sqlcus="Select * from products where pid=".$_GET['userid']; 
					  $sqlexe=mysql_query($sqlcus);
					  $rowc=mysql_fetch_array($sqlexe);
						
						?>
                    <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#F2F1EE">
                      <form action="custmerinsert.php?action=add" method="post" enctype="multipart/form-data" name="frm" id="frm" onsubmit="return validate(this);">
                        <tr>
                          <td height="17" align="center" bgcolor="#D7D6CC" class="dataTableHeadingContent"><table cellspacing="0" cellpadding="0">
                            <tr>
                              <td><strong><? echo $rowc['pname']; ?></strong></td>
                            </tr>
                          </table></td>
                        </tr>
                        <tr>
                          <td height="10" align="center"><strong><span id="errorMessage"></span></strong></td>
                        </tr>
                        <tr>
                          <td height="25" align="center" valign="top">
                         <a href="updatefeature.php?userid=<? echo $rowc['pid'];  ?>"> 
                          <img src="images/button_edit.gif" border="0" />
                          </a>
                          
                          
                          <a href="viewfeatured.php?userid=<? echo $rowc['pid'];  ?>&del=del"><img src="images/button_delete.gif" width="65" height="22" border="0" /></a>
                          
                          
                       </td>
                        </tr>
                        <tr>
                          <td height="25" align="center" valign="bottom" style="padding-left:5px;">&nbsp;</td>
                        </tr>
                        <tr>
                          <td align="center">&nbsp;</td>
                        </tr>
                        <tr>
                          <td align="left"><span class="infoBoxContent">&nbsp;&nbsp;Date Added: <? echo $rowc['add_date'];  ?></span></td>
                        </tr>
                        <tr>
                          <td align="left">&nbsp;&nbsp;Last Modified<span class="infoBoxContent">:<? echo $rowc['mod_date'];  ?></span></td>
                        </tr>
                        <tr>
                          <td align="center">&nbsp;</td>
                        </tr>
                        <tr>
                          <td align="center">&nbsp;</td>
                        </tr>
                        <tr>
                          <td align="center"><label></label></td>
                        </tr>
                        <tr>
                          <td>&nbsp;</td>
                        </tr>
                      </form>
                    </table>
                  <? } elseif($_GET['del']=='del')
				  {
					  $sqlcus="Select * from products where pid=".$_GET['userid']; 
					  $sqlexe=mysql_query($sqlcus);
					  $rowc=mysql_fetch_array($sqlexe);?>
                    
                   
                    <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#F2F1EE">
                      <form action="featureinsert.php?action=delete" method="post" enctype="multipart/form-data" name="frm" id="frm" onsubmit="return validate(this);">
                        <tr>
                          <td height="17" align="center" bgcolor="#D7D6CC" class="dataTableHeadingContent"><table cellspacing="0" cellpadding="0">
                            <tr>
                              <td><strong><? echo $rowc['pname']; ?></strong></td>
                            </tr>
                          </table></td>
                        </tr>
                        <tr>
                          <td height="10" align="center"><strong><span id="errorMessage"></span></strong></td>
                        </tr>
                        <tr>
                          <td height="25" align="center" valign="top">&nbsp;&nbsp;
                       <input type="image" src="images/button_delete.gif" border="0" />
                       <input type="hidden" name="userid" value="<?  echo $_GET['userid']; ?>"/>
                          
                           </td>
                        </tr>
                        <tr>
                          <td height="25" align="center" valign="bottom" style="padding-left:5px;"><a href="delete.php"></a> Are you sure you want to delete this category? &nbsp;<a href="email.php"></a>&nbsp;</td>
                        </tr>
                        <tr>
                          <td align="center">&nbsp;</td>
                        </tr>
                        <tr>
                          <td align="center"><label></label></td>
                        </tr>
                        <tr>
                          <td>&nbsp;</td>
                        </tr>
                      </form>
                    </table>
                    <? } elseif($_GET['sdel']=='sdel')
				  {?>
            <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#F2F1EE">
                      <form action="featureinsert.php?action=delete" method="post" enctype="multipart/form-data" name="frm" id="frm" onsubmit="return validate(this);">
                        <tr>
                          <td height="17" align="center" bgcolor="#D7D6CC" class="dataTableHeadingContent"><table cellspacing="0" cellpadding="0">
                            <tr>
                              <td><strong></strong></td>
                            </tr>
                          </table></td>
                        </tr>
                        <tr>
                          <td height="10" align="center"><strong><span id="errorMessage"></span></strong></td>
                        </tr>
                        <tr>
                          <td height="25" align="center" valign="top">&nbsp;
                          <span class="style2"><img src="images/delete.gif"/>Delete successfully</span></td>
                        </tr>
                        <tr>
                          <td align="center"></td>
                        </tr>
                        <tr>
                          <td>&nbsp;</td>
                        </tr>
                      </form>
                    </table>      
                  
                  
                  <? } ?>
                  
                  
                  
                  
                  
                  
                  
                  
                  
                     </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>
