<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php
  /* STEP 1: LOAD RECORDS - Copy this PHP code block near the TOP of your page */

  // load viewer library
  $libraryPath = 'bcmAdmin/lib/viewer_functions.php';
  $dirsToCheck = array('/home/vournas/public_html/','','../','../../','../../../');
  foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
  if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }

  // load records
  list($cat_itemsRecords, $cat_itemsMetaData) = getRecords(array(
    'tableName'   => 'cat_items',
    'loadUploads' => '0',
    'allowSearch' => '0',
  ));

  // load records
  list($used_itemsRecords, $used_itemsMetaData) = getRecords(array(
    'tableName'   => 'used_items',
    'loadUploads' => '0',
    'allowSearch' => '0',
  ));

?>
<!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=utf-8" />
<title>Vournas Test</title>
<link href="css/styles.css" rel="stylesheet" type="text/css" media="screen">
</head>

<body>

<div class="container">
  <div class="sidebar1">
    <ul class="nav">
		<?php $cat_count=array(); 
			foreach($used_itemsRecords as $used_item){ 
			@$cat_count[$used_item['item']]++; 
			}
		?>
		<?php foreach ($cat_itemsRecords as $record): ?>
			<li><a href="<?php echo $record['_link'] ?>"><?php echo $record['name']; ?>&nbsp;(<?php echo intval(@$cat_count[$record['name']]); ?>)</a></li>
		<?php endforeach ?>
	</ul>
    <!-- end .sidebar1 --></div>
  <div class="content">
    <!-- end .content --></div>
  <!-- end .container --></div>
</body>
</html>
