Guest User

favorite system k2

a guest
Mar 10th, 2011
631
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.18 KB | None | 0 0
  1. <?php
  2. //don't allow other scripts to grab and execute our file
  3. defined('_JEXEC') or die('Direct Access to this location is not allowed.');
  4.  
  5. //User Information
  6. $user =& JFactory::getUser();
  7. $username = $user->username;
  8. $userid = $user->id;
  9.  
  10. if (!$user->guest){
  11. //Queries
  12. $query = "SELECT * FROM jos_k2_fav_xref WHERE userID = '$userid' ORDER BY id DESC";
  13.  
  14. $result = mysql_query($query) or die(mysql_error());
  15.  
  16. if (!result) {
  17.     echo "You have nothing in your favorites!";
  18. } else {
  19.  
  20.         while($row = mysql_fetch_assoc($result))
  21.           {
  22.             $catID = $row['catID'];
  23.             $itemID = $row['itemID'];
  24.             $title = $row['title'];
  25.             echo "<h3 style='font-size:130%;'><a href='index.php?option=com_k2&Itemid=184&id=".$itemID."&lang=en&view=item'>".$title."</a></h3>";
  26.             echo "
  27.             <span class='userItemImage'>
  28.             <a href='index.php?option=com_k2&Itemid=184&id=".$row['itemID']."&lang=en&view=item'>
  29.             <img src=".JURI::root()."media/k2/items/cache/".md5("Image".$itemID)."_M.jpg />
  30.             </a>
  31.             </span>";
  32.             echo "</br>";
  33.           }
  34. }
  35. } else {
  36.     echo "You are not logged in! If you do not have an account, please <a name='reg' title='Register' alt='msiubox' class='msiubox'>register</a>!";
  37. }
  38.  
  39.  
  40. ?>
Advertisement
Add Comment
Please, Sign In to add comment