MichaelB
Member
I am not a php/mysql coder but I am trying to learn the basics for what I need. I want to read the value from a certain field in a table and then display it on the user info panel on the sidebar. The table is "xf_user" and the field is "reviews_count". Since this is user specific, it will need to display the value for the logged in user.
Below is what I have but I'm not sure how to display it on the sidebar area or if it is even correct at all. Of course, I would create the ReadCount.php file and place it in library/Reviews/Model/ folder.
I read on another page that the following code would be used to get a value but do I replace 'user_id' with 'reviews_count' and 'xf_admin' with 'xf_user'? Once the code is correct in grabbing the value, how do I display it on the page? Assuming a callback function is needed?
Below is what I have but I'm not sure how to display it on the sidebar area or if it is even correct at all. Of course, I would create the ReadCount.php file and place it in library/Reviews/Model/ folder.
Code:
<?php
class Reviews_Model_ReadCount extends XenForo_Model
{
public function getReviewsCount($reviews_count)
{
return $this->_getDb()->fetchRow('
SELECT * FROM xf_user WHERE reviews_count = ?', $reviews_count);
}
}
?>
I read on another page that the following code would be used to get a value but do I replace 'user_id' with 'reviews_count' and 'xf_admin' with 'xf_user'? Once the code is correct in grabbing the value, how do I display it on the page? Assuming a callback function is needed?
Code:
$db->fetchCol("SELECT `user_id` FROM `xf_admin`");
Code:
<xen:callback class="Reviews_Model_ReadCount" method="getReviewsCount"></xen:callback>