<?php
require_once ("../config.inc.php");
require_once ("../includes/adminlogincheck.inc.php");
require_once ("../includes/mysql.inc.php");
require_once ("../includes/Pager/Pager.php");

$message	= "";
$pages		= "";
$data		= array();
$array		= array();
$page		= isset($_REQUEST['page'])	?	trim($_REQUEST['page'])	:	"1";

if (!$objDB) 
{
	$message	= "Unable to Locate Database Server.";
}//end if
else 
{

	$query="SELECT h.*,hc.* FROM ".TABLEPREFIX."Help h left join ".TABLEPREFIX."HelpCategory hc on h.hcid=hc.hcid 
													where hc.htype='admin' and h.active='1' GROUP BY h.hcid ORDER BY h.hposition desc";

	$res=mysql_query($query) or die(mysql_error());
	$cnt=mysql_num_rows($res);

	if (@mysql_num_rows($res) > 0) 
	{
		while($row = @mysql_fetch_array($res)) 
		{
			$array[]	= $row;
		}//end while loop
		@mysql_free_result($res);
	}//end if
	
	$params 	= array(
		'mode'      => 'Sliding',
		'perPage'   => PAGESIZE,
		'urlVar'    => 'page',
		'extraVars' => array(),
		'itemData'  => $array
	);
	$objP 		= & Pager::factory($params);
	$data  		= $objP->getPageData();
	if (empty($data))
		$message	.= "No record(s) exists.<br>";
}//end else

include_once('title.inc.php');
?>
<?php include_once('tophtml.php');?>
<table width="100%"  border="0" cellspacing="5" cellpadding="0">
  <tr>
    <td valign="top" class="white"><table width="100%"  border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="72%" valign="top"><?php include_once('tophtml.php');?>
			<table width="100%"  border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td><table width="100%"  border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="32%" class="headings1">Admin Help Listings</td>
                </tr>
            </table></td>
          </tr>
        </table>

            <div class="bordernew padding2">
          <table width="100%"  border="0" cellspacing="0" cellpadding="5">
            <tr>
              <td><table width="100%"  border="0" cellspacing="0" cellpadding="0">
				<?php if ($objDB) 
					  { 
                 			if (!empty($data)) 
							{ 
								foreach ($data as $key => $value) 
								{ 
									echo '<tr align="left"><td height="40" align="center" class="maintext2 ">&nbsp;</td>
                  							<td colspan="2" class="maintext2 sb-hd02"><strong class="">'.htmlspecialchars(stripslashes($value['hctitle'])).'</strong></td>
                  							</tr>';
									$contents=mysql_query("SELECT * FROM ".TABLEPREFIX."Help where active='1' and hcid='".$value['hcid']."' ORDER BY hposition desc") 
										or die(mysql_error());
									if(mysql_num_rows($contents)>0)
									{
										while ($row = mysql_fetch_array($contents))  
                        {
				?>
                <tr align="left">
                  <td width="1%" align="center" class="maintext2">&nbsp;</td>
                  <td width="3%" align="center" valign="middle" class="maintext2"><a href="help_details.php?id=<?php echo $row['hid'];?>&name=<?php echo $row['htitle'];?>&page=<?php echo $_GET['page']?>" class="maintext"><img src="../help/<?php echo $row['himage'];?>" width="22" height="20" alt="<?php echo $row['htitle'];?>" border="0"></a></td>
                  <td width="96%" class="maintext2"><a href="help_details.php?id=<?php echo $row['hid'];?>&name=<?php echo $row['htitle'];?>&page=<?php echo $_GET['page']?>" class="maintext"><?php echo $row['htitle'];?></a></td>
                </tr>
				<?php 			}//end for loop
									}//end if
							}//end foreach
				?>
			   <tr align="left">
                  <td align="center" class="maintext2">&nbsp;</td>
                  <td colspan="2" class="maintext2">&nbsp;</td>
                  </tr>
			   <?php
					 		}//end if
						}//end first if
				?>
              </table>
				<?php if(!empty($data))
					  {
				?>
                 <table width="100%"  border="0" cellspacing="0" cellpadding="0">
                                                <tr>
                                                    <td width="82%">&nbsp;</td>
                                                    <td width="18%" align="right">
                                                        <table border="0" cellspacing="0" cellpadding="5" class="pagination_style">
                                                            <tr align="center">
                                                                <td><?php echo $objP->links;?></td>
                                                            </tr>
                                                        </table>
                                                    </td>
                                                </tr>
                                            </table><?php }//end if?>
                <table width="100%"  border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td align="right"><table width="100%"  border="0" cellspacing="0" cellpadding="0">
                      <tr>
                        <td>&nbsp;</td>
                      </tr>
                    </table>
                     </td>
                  </tr>
                </table></td>
            </tr>
          </table></div></td>
        </tr>
    </table>      
    </td>
  </tr>
</table>
<?php include_once('bottomhtml.php');?>