Keyword

[SOLVED] retrieve count of items of user

  • George Nasis
  • George Nasis's Avatar Topic Author
  • Offline
  • Elite Member
More
9 years 3 months ago #144863 by George Nasis
retrieve count of items of user was created by George Nasis
hallo there,

i am trying to retrieve the sum of the items a user has post

in the item.php i have written this one but it does not work
          <?php $created_user_id = $this->item->created_by; ?>
          <?php $db = JFactory::getDBO(); ?>
          <?php  $select = "SELECT COUNT(*) FROM #__k2_items WHERE created_by=$created_user_id"; ?>
          <?php $db->setQuery($select); ?>
     	  <?php echo $select; ?>

any ides??

thank you

Please Log in or Create an account to join the conversation.

  • George Nasis
  • George Nasis's Avatar Topic Author
  • Offline
  • Elite Member
More
9 years 3 months ago #144866 by George Nasis
Replied by George Nasis on topic retrieve count of items of user
ok i found the mistake,

this one is working
<?php $created_user_id = $this->item->created_by; ?>
<?php $db = JFactory::getDBO(); ?>
<? php $select = "SELECT COUNT(*) FROM #__k2_items WHERE created_by=$created_user_id"; ?>
<? php $db->setQuery($select); ?>
<? $resultitems = $db->loadresult(); ?>
<?php echo $resultitems; ?>

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
9 years 3 months ago #144890 by Krikor Boghossian
Replied by Krikor Boghossian on topic retrieve count of items of user
Kudos George :)

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum