<?php     
	require_once "../lib/viewer_functions.php";
	
	$GLOBALS['WSF_SCRIPTS_LOADED'] = true;

	// get favorite record nums
	$tableOrTag        = mysql_escape('sale');
	$currentUserNum    = mysql_escape( @$CURRENT_USER['num'] );
	$favoriteNumsQuery = "SELECT recordNum FROM {$TABLE_PREFIX}_website_favorites WHERE tableOrTag = '$tableOrTag' AND createdByUserNum = '$currentUserNum'";
	
	// load matching records     
	list($favoriteRecords, $favoriteMetaData) = getRecords(array(
		'tableName'     => 'sale',
		'perPage'       => '10',
		'where'         => " num IN ($favoriteNumsQuery) ",
		'loadCreatedBy' => false,
		'allowSearch'   => false,
	));
	
	print_r($currentUserNum);
	print_r($favoriteRecords);
	
?>


   <h2>Favorites</h2>
  <?php foreach ($favoriteRecords as $record): ?>
    <?php
      $tableOrTag = 'sale';     // Update with your section's table name
      $recordNum  = $record['num'];  // Update this with current record number
	?>

    <div class="<?php wsf_cssClassFor($tableOrTag, $recordNum, 'remove'); ?>"
         style="<?php wsf_displayStyleFor($tableOrTag, $recordNum, 'remove'); ?>">
      <a href="<?php echo $record['_link'] ?>"><?php echo $record['title'] ?></a> -
      <a href="#" onclick="<?php wsf_onClickFor($tableOrTag, $recordNum, 'removeAndReload'); ?>">Remove</a>
    </div>
  <?php endforeach; ?>

  <?php if (!$favoriteRecords): ?>
     You don't have any favorites yet.
  <?php endif; ?>