coralnutz
09-24-2007, 04:16 AM
Well I'm trying to get the overall feedback rating from photopost classifieds to show in the vbulletin profile page.
So I've made a file called getfeedback.php and put it in my includes folder for vb.
Then in the member.php file for vbulletin I've put this getfeedback.php as
require_once(DIR . '/includes/getfeedback.php');
In the getfeedback.php file I have the following code.
<?php
$dbhost = 'localhost';
$dbuser = 'database_username';
$dbpass = 'database_password';
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die
('Error connecting to mysql');
$dbname = 'database_name';
mysql_select_db($dbname);
$query = "SELECT foruser, rating, username
FROM cp_feedback
WHERE rating = 3
AND foruser = 6";
$result = mysql_query($query);
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
$ratingPosTotal += 1;
}
$query = "SELECT foruser, rating, username
FROM cp_feedback
WHERE rating = 1
AND foruser = 6";
$result = mysql_query($query);
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
$ratingNegTotal += 1;
}
$feedbackRatingTotal = $ratingPosTotal - $ratingNegTotal;
?>
So then in my MEMBERINFO template for vb I have added a line that will show $userinfo[username]'s Feedback Rating: $feedbackRatingTotal
and then this will show the users feedback rating score. But where I have this code:
AND foruser = 6";
it will obviously show the feedback rating for userid number 6, no matter who's profile your looking for. (this works, depending on what number I put in, it will work to the point of showing that users feedback rating)
I don't really know much about php so can someone help me, what would I insert to make it be AND foruser = whatever userid of the profile I'm looking at? I've tried just about everything I can think of but nothing is working. :(
So I've made a file called getfeedback.php and put it in my includes folder for vb.
Then in the member.php file for vbulletin I've put this getfeedback.php as
require_once(DIR . '/includes/getfeedback.php');
In the getfeedback.php file I have the following code.
<?php
$dbhost = 'localhost';
$dbuser = 'database_username';
$dbpass = 'database_password';
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die
('Error connecting to mysql');
$dbname = 'database_name';
mysql_select_db($dbname);
$query = "SELECT foruser, rating, username
FROM cp_feedback
WHERE rating = 3
AND foruser = 6";
$result = mysql_query($query);
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
$ratingPosTotal += 1;
}
$query = "SELECT foruser, rating, username
FROM cp_feedback
WHERE rating = 1
AND foruser = 6";
$result = mysql_query($query);
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
$ratingNegTotal += 1;
}
$feedbackRatingTotal = $ratingPosTotal - $ratingNegTotal;
?>
So then in my MEMBERINFO template for vb I have added a line that will show $userinfo[username]'s Feedback Rating: $feedbackRatingTotal
and then this will show the users feedback rating score. But where I have this code:
AND foruser = 6";
it will obviously show the feedback rating for userid number 6, no matter who's profile your looking for. (this works, depending on what number I put in, it will work to the point of showing that users feedback rating)
I don't really know much about php so can someone help me, what would I insert to make it be AND foruser = whatever userid of the profile I'm looking at? I've tried just about everything I can think of but nothing is working. :(