This topic is locked

Icon links - changed by users ratings

3/7/2009 8:23:25 AM
PHPRunner General questions
B
bruze author

Hi,

I'm trying to build a education site with the demo version of PHPRUNNER 5.
I have a page which lists links to diffrent video pages. I want the links to be shown as Icons, currently I have done this by manually inserting <img="images/icon1.gif"> between the <a href=""></a> tags...

But the problem is that I want the icons to be changable by users with a rating function.
I want users to be able to rate a education video and when they've rated the video, the "standard link icon" of that video changes to a average rating icon of what other users have rated.
Like if the average rating is "4", a image icon with the nr 4 is shown instead of the standard icon.
The icon of av "video link" must only change if a user has rated that video. So that the user can see which videos he/she has seen or not.
I have six icons , one of them is a standard icon image and the others are five stars (with numbers on 1 to 5).
Iv'e tried by making a rating table called ratings with the fields = rating_id, video_id, user_id and rating_grade.
and a table called icons with the fields: icon_id, icon. And then connected the "icon" via a dropdown lookup masterpage relationship to rating tabel ->"rating_grade".
And on the bottom of each video page i've added a link to the "add rating" page..
But how can the links to the videos change icons depending on ratings...

I must probably change the table with the video links and add a icon field or something...
Thanks for help

J
Jane 3/10/2009

Hi,
here are some tips:

  1. create alias for video_id field on the Edit SQL query tab:
    select video_id,

    video_id as video_id_b,

    ...

    from TableName


2. set up video_id_b as custom on the "View as" settings dialog on the Visual Editor tab.

Here is a sample code:

$str = "select rating_id, video_id, user_id, rating_grade,icon_id, icon from ratings inner join icons on ratings.rating_grade=icons.icon_id where video_id=".$value." and user_id='".$_SESSION["UserID"]."'";

$rs = db_query($str,$conn);

$data = db_fetch_array($rs);

$value = "<img src=\"".$data["icon"]."\">".$rating_grade;

B
bruze author 3/21/2009

Hi Jane,

I solved it in an other way before I got your awnser, but I'll use the code you wrote for a modification.
Thanks