CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 Rating whit stars

Print topic Send  topic

Author Message
gerrit


Posts: 131
Posted: 10/30/2008, 9:05 AM

hi,
Im Looking for a rating example

I wanna use it lyke dis http://www.gotocode.com/artlist.asp


_________________
| http://www.vision.to |
View profile  Send private message
melvyn


Posts: 333
Posted: 10/30/2008, 9:18 AM

I've done something similar here:
http://www.unacajitadesorpresas.com/app/fotos.php click on a picture, you vote them and votes quantity is displayed below each picture. It can be changed and when the votes are 2 use a imagen 3.stars.jpg, it's the same procedure.

Do you speak spanish? lye => like; dis => this. Im => I'm
_________________
Melvyn Perez
Puro Codigo
http://purocodigo.com
View profile  Send private message
melvyn


Posts: 333
Posted: 10/30/2008, 11:54 AM

Quote :
My problem is I can rating but only whit numbers, I need a code to show my stars, but how can I make this ! I get 5 stars

Well, if you get working with numbers, it's very simple. My question: Do you get the number of stars? Let's say
product stars
product 112 - 3
product 287 - 5
product 86 - 2

if so, then you're done!!!
Right now, your current code looks like:
  
<tr>  
<td> {product} </td>   
<td> {stars} </td>   
</tr>  

Change to:
  
<tr>  
<td> {product} </td>   
<td> <img src="images/stars/{stars}.jpg"> </td>   
</tr>  

So, when a value is retrieved from database as 4 (four stars) that will show a picture named 4.jpg located in "images/stars/4.jpg"

Do you understand?
Post your code snippet here and let's solve it.


_________________
Melvyn Perez
Puro Codigo
http://purocodigo.com
View profile  Send private message
gerrit


Posts: 131
Posted: 10/30/2008, 12:28 PM

hi,

I get a tabel with articles.
whit a label ( art_id , art_name, art_rating, art_rating_count )
and I get stars images, ( stars1.gif, stars2.gif ..........)
art_rating is a list box whit 5;Extremely Helpful;4;Very Helpful;3;Helpful;2;Not Helpful;1;Waste of Time.

now I need a code in the before Show !

_________________
| http://www.vision.to |
View profile  Send private message
melvyn


Posts: 333
Posted: 10/31/2008, 9:23 AM

gerrit,

I guess you're getting the calculated number (sum of art_rating / art_rating_count).

If you get: the rating for this articule is 2, then you're solved.
Your label report rating as 1, 2, 3, 4, 5....

Then edit your html and you'll find a label with {art_rating}

Edit and change to
<img src="images/stars{art_rating}.gif" >

{art_rating} will be replaced with the integer value and become
<img src="images/stars1.gif" >
<img src="images/stars2.gif" >
....
_________________
Melvyn Perez
Puro Codigo
http://purocodigo.com
View profile  Send private message
jjrjr1


Posts: 942
Posted: 11/01/2008, 12:25 PM

Hi.

Here is the code that will do it for you.

Create an image on your page named Stars.
Create a hidden field on your page named Rating.

Before Show for Rating put into the field totalratingvalue / number of total ratings (totalratingvalue & number of ratings can also be hidden fields on your form in order to get it from the database table)

Be sure your star images are located where the setvalue() says:

Here is a sample.

http://ccselite.com/online_store.php

Then on the before show event for Stars place the custom code below.

if ($Container->Rating->GetValue() <= 0 ){$Container->Stars->SetText("./images/00star.gif");}
if ($Container->Rating->GetValue() >= 0.5){$Container->Stars->SetText("./images/05star.gif");}
if ($Container->Rating->GetValue() >= 1 ){$Container->Stars->SetText("./images/1star.gif");}
if ($Container->Rating->GetValue() >= 1.5){$Container->Stars->SetText("./images/15star.gif");}
if ($Container->Rating->GetValue() >= 2 ){$Container->Stars->SetText("./images/2star.gif");}
if ($Container->Rating->GetValue() >= 2.5){$Container->Stars->SetText("./images/25star.gif");}
if ($Container->Rating->GetValue() >= 3 ){$Container->Stars->SetText("./images/3star.gif");}
if ($Container->Rating->GetValue() >= 3.5){$Container->Stars->SetText("./images/35star.gif");}
if ($Container->Rating->GetValue() >= 4 ){$Container->Stars->SetText("./images/4star.gif");}
if ($Container->Rating->GetValue() >= 4.5){$Container->Stars->SetText("./images/45star.gif");}
if ($Container->Rating->GetValue() >= 5 ){$Container->Stars->SetText("./images/5star.gif");}

One advantage of this method is you can half star increments that can be displayed from the caluclated value of totalratingvalue / number of ratings.

Let me know if you need the images and more information.

Have fun


_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com
View profile  Send private message
jjrjr1


Posts: 942
Posted: 11/01/2008, 11:50 PM

Hi Gerrit

I created a full working set of pages for you and set them up as CCP files you can modify and integrate into your project.

It is avialable here.

http://ccselite.com/online_store.php?pid=13

This is an example of how full membership in CCSElite will work.

You do not have to be a member to get a solution from a member but you do to post one for sale.

Many members of this forum had set up donate buttons for solutions. Here is where CCSElite has taken it to the next better level. A member can assign a price to his solution and put it for sale on CCSElite for everyone.

We all need to earn money in what we all do for a living. This is a fair and equitable way to do that.

Let me know if this helps

Have Fun

_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com
View profile  Send private message
maxhugen

Posts: 272
Posted: 11/10/2008, 2:29 PM

The same result can be achieved using a single image and CSS. Here's an example of the image:

The CSS would look like:
.rating {  
    background-image: url(http://www.yourDomain.com/img/star.gif);  
    background-repeat: no-repeat;  
    width:55px;  
    height:13px;  
    border-width:0;  
}  
.rating_00 {background-position: -55px   0px;}  
.rating_05 {background-position: -44px -13px;}  
.rating_10 {background-position: -44px   0px;}  
.rating_15 {background-position: -33px -13px;}  
.rating_20 {background-position: -33px   0px;}  
.rating_25 {background-position: -22px -13px;}  
.rating_30 {background-position: -22px   0px;}  
.rating_35 {background-position: -11px -13px;}  
.rating_40 {background-position: -11px   0px;}  
.rating_45 {background-position:   0px -13px;}  
.rating_50 {background-position:   0px   0px;}  
  
.rating_onestar_on {  
    width:11px;  
    background-position: 0px 0px;  
}  
.rating_onestar_off {  
    width:11px;  
    background-position: -55px 0px;  
}

Then,using John's example above, you would set the CSS class, instead of the image source. You can see it working at http://www.chrisarminson.com.

HTH
_________________
Max
www.gardenloco.com | www.eipdna.com | www.chrisarminson.com
View profile  Send private message
jjrjr1


Posts: 942
Posted: 11/10/2008, 6:07 PM

I like it Max

Thanks

If you get a chance why not post the entire solution at http://ccselite.com

Have fun

_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com
View profile  Send private message
maxhugen

Posts: 272
Posted: 11/22/2008, 10:47 PM

Hi John

:-< Just found an unfortunate side-effect of using "technically correct" CSS : as the image is set as a background, it will not print by default in most modern browsers.

I tried everything else I could think of; wapping an <img> in a <div>, and playing with the css property clip:rect(0px 55px 13px 0px)... but to no avail.

Looks like I'll have to go back to using separate images as per your example, just so I can get it to print.

Pity.
_________________
Max
www.gardenloco.com | www.eipdna.com | www.chrisarminson.com
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.