<?php session_start();  //Developed by ITechScripts
require 'include/configurations.php'; // ITECHBIDS Configuration File
$cat_id=$_GET['id'];
$mode=$_GET['mode'];
?>
<html>
<body>
><?php
require 'include/header.php';
?>

<p>&nbsp;</p>
<table width="90%" border="0" cellpadding="5" cellspacing="1" class="ft" align="center">
<form name="category" method="post" action="addcategory.php">
         <tr  class="ct">
<td width="10%"><div align="center"><span height="25">Serial </span></div></td>
        <td width="25%"><div align="center"><span height="25">Category </span></div></td>
		
        <td width="27%"><div align="center"><span height="25">Edit</span></div></td>
        <td width="22%"height="25"><div align="center">Delete</div></td>
		</tr>
		
<?

if($mode=='delete')
{
$sql1="delete from site_categories where category_id='$cat_id'";
$del=mysql_query($sql1);
if($del)
$message="Category deleted sucessfully";
else
$message="Category not deleted ";
}
$mode='';
 if(!empty($message))
{
echo "<tr><td align=center colspan=3><font color=red size=2>$message</font></td></tr>";
}

if($mode=='edit')
{
}
$sql="select * from site_categories where category_head_id=0 order by serial";
$res=mysql_query($sql);
$row=mysql_fetch_array($res);
$categoryid=$row['category_id'];
?><?php
	$total_records=mysql_num_rows($res);
	$curpage=$_GET['curpage'];
	if(strlen($_GET['curpage']) == 0) $curpage=1;
	$start=($curpage-1) * 10;
	$end=10;
	if($curpage==''|| $curpage==1)
	$i=1;
	else $i=$_GET['sno']+1;
	$sql.=" limit $start,$end";
	$res=mysql_query($sql);
 ?>


        <tr> 
          <td align="right" colspan="5"> 
            <?php
	     if($curpage!=1) 
	     {
         ?>
            <a href="category.php?mode=<?=$mode; ?>&curpage=<?=($curpage-1);?>" id="link2">Prev</a> 
            | 
            <?php
            }
           ?>
            <?php
           if($total_records > ($start + $end)) 
		   {
           ?>
            <a href="category.php?mode=<?=$mode; ?>&curpage=<?=($curpage+1);?>" id="link2">Next</a> 
            <?php
            }
            ?>
          </td>
        </tr>

        <?php
         while($row=mysql_fetch_array($res))
        {
        ?>		
	   <tr >
<td height="41" align="center"><?= $row['serial'];?></td>
       	   <td height="41" align="center"><?= $row['category_name'];?></td>
	   	   <td><div align="center" class="style3">
	    <a href="addcategory.php?id=<?=$row['category_id']; ?>&mode=edit" style="text-decoration:none" id="link1">Edit</a></div></td>
	   <td><div align="center" class="style3">
	   <a href="category.php?id=<?=$row['category_id']; ?>&mode=delete"  id="link1" style="text-decoration:none" onClick="javascript:return condelete();">Delete</a></div></td>
	   </tr>
	   <?
         }
       ?>	
	<tr>
    <tr><td>

</td></tr>
	<td align="center" colspan="3">
	
	<input type="submit" class="button"   name="add" value="Add Category" ></div>
	</td>
	<!-- <td ><input type="Button" name="change" value="Change Display Order"  onClick="itechitems_11();"></td> -->
	
  </form>
  

<?
	require 'include/footer.php';
?>
</td>
	</tr>
</table>
</body></html>
<script language="JavaScript">
function condelete()
{
var confrm;
confrm=window.confirm("Are You sure you want to delete this category");
return confrm;
}
function itechitems_11()
{
document.category.action="change_display_order.php";
document.category.submit();
}

</script>