Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Senior Coder o0O0o.o0O0o's Avatar
    Join Date
    Jan 2008
    Location
    C:\Windows\System32
    Posts
    1,018
    Thanks
    19
    Thanked 9 Times in 9 Posts

    how to show stars , rating in php

    HI ,

    I want to show the rating stars in the column. Is there any easy way to do that in php. I have 1-5 levels stored in databse.
    Please de-reputate me
    © 0o0o0o0

    Its better to rule in Hell then to serve in Heaven

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,538
    Thanks
    8
    Thanked 1,093 Times in 1,084 Posts
    I would do it this way ...

    Create 5 different .gif images, representing the 5 stars.
    Name them like ... star1.gif, star2.gif, star3.gif, star4.gif, star5.gif

    Then, display the correct one based off the value in the database.

    $s = 4;
    $star = "star".$s.".gif";
    echo"
    <img src='$star' alt='rated $s stars' title='rated $s stars' />
    ";

  • #3
    Regular Coder
    Join Date
    Oct 2008
    Posts
    214
    Thanks
    5
    Thanked 22 Times in 22 Posts
    Or you can also only have one star image that is repeated (the number stored in the DB must be the number or stars)...

    PHP Code:
    for ($i 0$i $starsCount$i++) //$starsCount is a DB value
        
    echo('<img src="/images/star.png" alt="*" title="">'); 


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •