<?php require_once('Connections/LocalPHP.php'); ?>
<div class="productmaster">
  <?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$currentPage = $_SERVER["PHP_SELF"];

$maxRows_rs_products = 6;
$pageNum_rs_products = 0;
if (isset($_GET['pageNum_rs_products'])) {
  $pageNum_rs_products = $_GET['pageNum_rs_products'];
}
$startRow_rs_products = $pageNum_rs_products * $maxRows_rs_products;

mysql_select_db($database_LocalPHP, $LocalPHP);
$query_rs_products = "SELECT * FROM products ORDER BY product_ID ASC";
$query_limit_rs_products = sprintf("%s LIMIT %d, %d", $query_rs_products, $startRow_rs_products, $maxRows_rs_products);
$rs_products = mysql_query($query_limit_rs_products, $LocalPHP) or die(mysql_error());
$row_rs_products = mysql_fetch_assoc($rs_products);

if (isset($_GET['totalRows_rs_products'])) {
  $totalRows_rs_products = $_GET['totalRows_rs_products'];
} else {
  $all_rs_products = mysql_query($query_rs_products);
  $totalRows_rs_products = mysql_num_rows($all_rs_products);
}
$totalPages_rs_products = ceil($totalRows_rs_products/$maxRows_rs_products)-1;

$queryString_rs_products = "";
if (!empty($_SERVER['QUERY_STRING'])) {
  $params = explode("&", $_SERVER['QUERY_STRING']);
  $newParams = array();
  foreach ($params as $param) {
    if (stristr($param, "pageNum_rs_products") == false && 
        stristr($param, "totalRows_rs_products") == false) {
      array_push($newParams, $param);
    }
  }
  if (count($newParams) != 0) {
    $queryString_rs_products = "&" . htmlentities(implode("&", $newParams));
  }
}
$queryString_rs_products = sprintf("&totalRows_rs_products=%d%s", $totalRows_rs_products, $queryString_rs_products);
?>
</div>
<!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"><!-- InstanceBegin template="/Templates/mygreen_temp_17.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>Green Start Association - Check out our great products</title>
<!-- InstanceEndEditable -->
<link href="mygreen_styles.css" rel="stylesheet" type="text/css" />
<link href="print_styles.css" rel="stylesheet" type="text/css" media="print" />
<script src="SpryAssets/SpryMenuBar.js" type="text/javascript"></script>
<link href="SpryAssets/SpryMenuBarVertical.css" rel="stylesheet" type="text/css">
<!-- InstanceBeginEditable name="head" -->
<!-- InstanceEndEditable -->
</head>

<body>

<div class="container">
  <div id="logo"><img src="images/butterfly-ovr.gif" width="170" height="150" alt="GreenStart Logo" /></div>
  <div class="header"><!-- end .header --><a name="top" id="top"></a></div>
  <div id="h-navbar"><a href="#">Home</a> | <a href="about_us.html">About Us</a> | <a href="contact_us.html">Contact Us</a></div>
  <!-- InstanceBeginEditable name="SideContent" -->
  <div class="sidebar1"><!-- #BeginLibraryItem "/Library/vertical-nav.lbi" -->
<ul id="MenuBar1" class="MenuBarVertical">
  <li><a href="news.html">Green News</a></li>
  <li><a href="products.php">Green Products</a></li>
  <li><a class="MenuBarItemSubmenu" href="events.asp">Green Events</a>
    <ul>
      <li><a href="events.asp#calendar">2010 Events Calendar</a></li>
      <li><a href="events.asp#classes">2010 Class Schedule</a></li>
    </ul>
  </li>
  <li><a href="travel.html">Green Travel</a></li>
  <li><a href="tips.html">Green Tips</a></li>
</ul>
<!-- #EndLibraryItem --><img src="images/backpack.jpg" alt="" name="Sidebar" width="180" height="180" id="Sidebar" />
<p class="hide4hh">Our line of eco-friendly products combine good science with good taste. <!-- end .sidebar1 --></p></div>
  <!-- InstanceEndEditable --><!-- InstanceBeginEditable name="MainContent" -->
  <div class="content">
    <h1>GreenStart offers only the best in green products</h1>
    <p>Click on any product link that you wish to learn more about.</p>
    <?php do { ?>
      <div class="productmaster">
        <p><a href="product_detail.php?product_ID=<?php echo $row_rs_products['product_ID']; ?>"><img src="products/<?php echo $row_rs_products['product_pix_sm']; ?>" alt="" width="100" height="100" /></a></p>
        <h3><a href="<?php echo $row_rs_products['']; ?>"><?php echo $row_rs_products['product_name']; ?></a></h3>
        <p><?php echo $row_rs_products['product_desc_short']; ?></p>
        <p><?php echo $row_rs_products['product_size']; ?></p>
      </div>
      <?php } while ($row_rs_products = mysql_fetch_assoc($rs_products)); ?>
    <table id="master-paging">
      <tr>
        <td><a href="<?php printf("%s?pageNum_rs_products=%d%s", $currentPage, 0, $queryString_rs_products); ?>">&lt;&lt; First</a></td>
        <td><a href="<?php printf("%s?pageNum_rs_products=%d%s", $currentPage, max(0, $pageNum_rs_products - 1), $queryString_rs_products); ?>">&lt; Previous</a></td>
        <td><a href="<?php printf("%s?pageNum_rs_products=%d%s", $currentPage, min($totalPages_rs_products, $pageNum_rs_products + 1), $queryString_rs_products); ?>">Next &gt;</a></td>
        <td><a href="<?php printf("%s?pageNum_rs_products=%d%s", $currentPage, $totalPages_rs_products, $queryString_rs_products); ?>">Last &gt;&gt;</a></td>
      </tr>
      <tr>
        <td colspan="4">Records <?php echo ($startRow_rs_products + 1) ?> to <?php echo min($startRow_rs_products + $maxRows_rs_products, $totalRows_rs_products) ?> of <?php echo $totalRows_rs_products ?></td>
      </tr>
    </table>
    <!-- end .content -->
  </div>
  <!-- InstanceEndEditable -->
  <div class="footer">
    <p>Copyright 2010 Meridien GreenStart, All rights reserved.</p>
    <!-- end .footer --></div>
<!-- end .container --></div>
<script type="text/javascript">
var MenuBar1 = new Spry.Widget.MenuBar("MenuBar1", {imgRight:"SpryAssets/SpryMenuBarRightHover.gif"});
</script>
</body>
<!-- InstanceEnd --></html>
<?php
mysql_free_result($rs_products);
?>
