<?php 
require("common_begin.php");

$itemID = $_GET['id'];
if (!isset($itemID))
  die("no item ID set");
  
$lst = Listopia::getInstance();

if ($lst->isLoggedIn() && $lst->isAdminUser())
{
/*
  $query = $lst->Database()->select(array(
                        'fields' => 'count(itemlikes.item_id) as counter, itemlikes.item_id, t_items.item_list, t_items.item_blurb, t_lists.list_headline, t_lists.list_id',
                        'table' => 'itemlikes',
                        'join' => 't_items on t_items.item_id = itemlikes.item_id join t_lists on t_lists.list_id = t_items.item_list',
                        'condition' => "itemlikes.vote = 'like'",
                        'group' => 'itemlikes.item_id',
                        'order' => 'counter desc',
                        'limit' => 20
                        ));
                        
                        
  print("<pre>");
  print_r($query);
  print("</pre>");
*/
  print("<br><hr><hr><br>");

  $itemLikesQueryCondition = 'itemlikes.item_id = ' . $itemID ;  

  $query = $lst->Database()->select(array(
                      'fields' => 'itemlikes.*, users.user_name',
                      'table' => 'itemlikes',
                      'join' => 'users on users.user_id = itemlikes.user_id',
                      'condition' => $itemLikesQueryCondition
                      ));
                  
  print("<pre>");
  print_r($query);
  print("</pre>");
}