Location: PHPKode > projects > Site Sift Listings > pages.php
<?php require_once('Connections/myconn.php'); ?>
<?php
$currentPage = $_SERVER["PHP_SELF"];
$pageNum_pages = 0;
if (isset($_GET['pageNum_pages'])) {
  $pageNum_pages = $_GET['pageNum_pages'];
}
$settings = mysql_fetch_assoc(mysql_query("select * from settings where id = '1'",$myconn));
$maxRows_pages = $settings['perPage'];
$startRow_pages = $pageNum_pages * $maxRows_pages;
$sort = ' order by '.$settings['sortBy'].' ';
//echo $sort;
mysql_select_db($database_myconn, $myconn);
$query_pages = "SELECT * FROM pages where mid = '0' and active = 'Yes' and catID = '" . $_REQUEST['id'] . "'" . $sort;
$query_limit_pages = sprintf("%s LIMIT %d, %d", $query_pages, $startRow_pages, $maxRows_pages);
$pages = mysql_query($query_limit_pages, $myconn) or die(mysql_error());
//$row_pages = mysql_fetch_assoc($pages);

if (isset($_GET['totalRows_pages'])) {
  $totalRows_pages = $_GET['totalRows_pages'];
} else {
  $all_pages = mysql_query($query_pages);
  $totalRows_pages = mysql_num_rows($all_pages);
}
$totalPages_pages = ceil($totalRows_pages/$maxRows_pages)-1;

$queryString_pages = "";
if (!empty($_SERVER['QUERY_STRING'])) {
  $params = explode("&", $_SERVER['QUERY_STRING']);
  $newParams = array();
  foreach ($params as $param) {
    if (stristr($param, "pageNum_pages") == false && 
        stristr($param, "totalRows_pages") == false) {
      array_push($newParams, $param);
    }
  }
  if (count($newParams) != 0) {
    $queryString_pages = "&" . htmlentities(implode("&", $newParams));
  }
}
$queryString_pages = sprintf("&totalRows_pages=%d%s", $totalRows_pages, $queryString_pages);

unset($settings);
$settings = mysql_fetch_assoc(mysql_query("select * from settings where id = '1'",$myconn));

?>
<link href="include/mystyle.css" rel="stylesheet" type="text/css">
<div class="pageText" align="right"> Results <?php if(mysql_num_rows($pages) > 0) echo ($startRow_pages + 1); else echo $startRow_pages; ?> to <?php echo min($startRow_pages + $maxRows_pages, $totalRows_pages) ?> of <?php echo $totalRows_pages ?></div>
<div align="center" class="pageLink">
<?php if ($pageNum_pages > 0) { // Show if not first page ?>
<a href="<?php echo gLink($row_category['title'],'subcat',$row_category['id'],$myconn); ?>" class="pageLink" style="color:<? echo $settings['catColor']; ?>;">First</a>
<?php } // Show if not first page ?>
<?php if ($pageNum_pages > 0) { // Show if not first page ?>
<a href="<?php echo gLink($row_category['title'],'subcat',$row_category['id'],$myconn,max(0, $pageNum_pages - 1)); ?>" class="pageLink" style="color:<? echo $settings['catColor']; ?>;">Previous</a>
<?php } // Show if not first page ?>
<?php if ($pageNum_pages < $totalPages_pages) { // Show if not last page ?>
<a href="<?php echo gLink($row_category['title'],'subcat',$row_category['id'],$myconn,max(0, $pageNum_pages + 1)); ?>" class="pageLink" style="color:<? echo $settings['catColor']; ?>;">Next</a>
<?php } // Show if not last page ?>
<?php if ($pageNum_pages < $totalPages_pages) { // Show if not last page ?>
<a href="<?php echo gLink($row_category['title'],'subcat',$row_category['id'],$myconn,$totalPages_pages); ?>" class="pageLink" style="color:<? echo $settings['catColor']; ?>;">Last</a>
<?php } // Show if not last page ?>
</div>
<? include('spages.php'); ?>
<?php if ($totalRows_pages > 0) { ?>
<table width="100%"  border="0" cellpadding="1" cellspacing="0" style="background-color:<?php echo $settings['tbColor']; ?>">
  <tr>
    <td><table width="100%"  border="0" cellpadding="1" cellspacing="0" style="background-color:<? echo $settings['tColor']; ?>">
      <tr>
        <td>
		<table border=0 cellpadding="4" cellspacing="0">
              <tr>
                <td><span class="pageTitle">Websites</span></td>
                <td>&nbsp;</td>
                <td width="100%" valign="middle"><table border=0 cellpadding=0 cellspacing=0 width="100%">
					<tr>
					  <td width="100%" style="background-color:<? echo $settings['lineColor']; ?>"><img src="images/spacer.gif" width=1 height=1></td>
					</tr>
				</table></td>
              </tr>
            </table>
		 <? while($page = mysql_fetch_assoc($pages)){ ?>
		 <?php
			  // calculate expired links and set expired ones to INactive
			  if ($page['exp'] > 0) {
				$exp_timestamp = (strtotime($page['pdate']) + (86400*$page['exp']));
				$cur_timestamp = strtotime(date("Y-m-d"));
				if ($cur_timestamp > $exp_timestamp) { //link has expired.
					mysql_query("update pages set active = 'Exp' where id = '" . $page['id'] . "'");
				}
			  }
		  ?>
          <div class="dirListing"><a href="<? echo gLink($pages['title'],'detail',$page['id'],$myconn); ?>" class="pageLink" style="color:<? echo $settings['ptColor']; ?>"><? echo $page['title']; ?></a>&nbsp;<? if($_SESSION['MM_UserGroup'] == 'Admin'){ ?><a href="edit.php?id=<? echo $page['id']; ?>" class="pageLink">(Edit)</a>&nbsp;<a href="javascript: if(confirm('Are you sure you want to delete this?')) window.location='delete.php?id=<? echo $page['id']; ?>'" class="pageLink">(Delete)</a><? } ?><br>
            <span class="pageText" style="color:<? echo $settings['pdColor']; ?>"><? echo $page['description']; ?><br><? if($settings['Rlink'] == 1) { echo $page['url']; } ?></span></div>
		  <? }?>
		<?
			if(mysql_num_rows($pages) <= 0) {
				echo '<span class="pageText">You could be the first one to <a href="' . $LINK_BASE;
				echo 'index.php?go=addpage&catid='.$row_category['id'];
				echo '" title="Click to submit link" class="pageLink" style="color:'.$settings['catColor'].'">place a link here';
			}
		?><BR>
		</td>
      </tr>
    </table></td>
  </tr>
</table><BR>
<?php } ?>
<?php if(mysql_num_rows($pages) <= 0) { ?>
<table width="100%"  border="0" cellpadding="1" cellspacing="0" style="background-color:<?php echo $settings['tbColor']; ?>">
  <tr>
    <td><table width="100%"  border="0" cellpadding="1" cellspacing="0" style="background-color:<? echo $settings['tColor']; ?>">
      <tr>
        <td>
		<?php
				echo '<span class="pageText">You could be the first one to <a href="' . $LINK_BASE;
				echo 'index.php?go=addpage&catid='.$row_category['id'];
				echo '" title="Click to submit link" class="pageLink" style="color:'.$settings['catColor'].'">place a link here';
		?><BR>
		</td>
      </tr>
    </table></td>
  </tr>
</table>
<?php } ?>
<?php
mysql_free_result($pages);
?>


Return current item: Site Sift Listings