Top Rated Module

orneis

Joined: 2008-03-01
Posts: 28
Posted: Mon, 2008-07-28 12:20

Hi, I am very very very new on php, sql queries and all that !!! So please bare with me and my code, I am totaly aware that it's not very beautifull!!

I would like to make something simple as retrieving the top rated items from the database without going into the gallery files.
What I made so far looks like this:

Quote:

<table width="493">
<tr>
<td width="33" height="58">Rank</td>
<td width="203">Thumb</td>
<td width="203">Title</td>
<td width="57">Moyenne</td>
<td width="40">Votes </td>
<td width="30">Clics</td>

</tr>
<?php
# Don't allow direct linking
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );

# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"

$hostname_ConnFour = "XXX";
$database_ConnFour = "XXX";
$username_ConnFour = "XXX";
$password_ConnFour = "XXX";
$ConnFour = mysql_pconnect($hostname_ConnFour, $username_ConnFour, $password_ConnFour) or trigger_error(mysql_error(),E_USER_ERROR);

mysql_select_db('XXX');

$sql = 'SELECT g2_RatingCacheMap.g_itemId, g_title, ROUND((g_averageRating*2)/1000, 1) AS moyenne, g_voteCount, g_renderer, g_pathComponent, g_userName, g_viewCount
FROM g2_RatingCacheMap,g2_Item, g2_FileSystemEntity, g2_User, g2_ItemAttributesMap
WHERE g_canContainChildren = "0" AND g2_Item.g_id=g2_RatingCacheMap.g_itemId AND g_userName Not Like "admin" AND g2_RatingCacheMap.g_itemId=g2_ItemAttributesMap.g_itemId AND g_averageRating >3500
GROUP by g_itemId
ORDER by moyenne DESC, g_voteCount DESC, g_viewCount DESC
';

$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());

while ($tableau= mysql_fetch_assoc($req))
{
echo '<tr><td>',$tableau['ranking'],'</td><td>',$tableau['g_pathComponent'],'</td><td>',$tableau['g_title'],'</td><td>',$tableau['moyenne'],'</td>
<td>',$tableau['g_voteCount'],'</td><td>',$tableau['g_viewCount'],'</td></tr> ';
}
?>
</table>

It's durty... I know.

But you can see what I want to do.

As you can also see, I dont know how to show the thumbnail of each item !!!

Basically, what I would like to know is:

1. How to show the thumbnails
2. How to link thumbnails to the item page
3. How to show owner Name
4. How to link owner Name to his profile on Community Builder
5. How to show the line Number each time (wich correspond to the rank) in the first column
And finally !!!!
6. How to show the Owner avatar from Community builder and link it to his profile.

The last one is tricky because Joomla/CB datas and the gallery datas are in 2 different databases !!

I know it's a lot, lot, lot... but I try and ask, maybe a helping and professional hand will find it easy to do.

Thanks in advance for you advices..
And if someone knows about an already existing module which does this, I would be glad to try it!!

 
orneis

Joined: 2008-03-01
Posts: 28
Posted: Tue, 2008-08-05 21:03

No idea here?

 
serbanc

Joined: 2006-05-19
Posts: 314
Posted: Tue, 2008-08-05 21:32

it's rather difficult to do it directly.

serbanc - www.e-poze.ro