SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Apr 2009
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Star Rating system

    Hi All,

    I'm currently working on creating a star rating system for my restaurant review website. I have the star rating system working. I am now trying to figure out how to make it so each restaurant webpage will have a star rating system, and also on another page a listing of all restaurants in a given city with each restaurant name followed by how many stars it is rated (so the viewer doesnt have to click on each individual restaurant to see its rating). If anyone could point me to a resource that discusses this or something like it, it would be appreciated.

    Thanks,

    Josh

  2. #2
    SitePoint Addict
    Join Date
    Nov 2008
    Location
    Peterborough, Ontario, Canada
    Posts
    316
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Josh, how are you storing the information? If it's in a database, just call the information out -- or if it's in a flat file (text) do the same thing...
    Have I helped you? You could help me.
    Like my business on facebook!
    Text message polls with real-time, live results.

  3. #3
    SitePoint Member
    Join Date
    Apr 2009
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Jeff-Thanks for the reply. I'm storing the ratings in SQL. I'm pretty new SQL but I figured the solution might be that simple. To be honest though, I'm not entirely sure the ratings are being stored properly. I'm using a star rating system based up this site: masugadesign (I can't post the actual URL because I'm a new poster) but Googling it brings it right up

    Josh

  4. #4
    SitePoint Addict
    Join Date
    Nov 2008
    Location
    Peterborough, Ontario, Canada
    Posts
    316
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sweet site. I love your design site.

    You've got a firm grasp of Ajax then this won't be too much for you.

    Do you have access to a database manager like phpmyadmin? If you do, just use your script and vote, then see if it's stored properly.

    To retrieve every single star rating you'll do something like this (you'll ofcourse replace everything in lowercase with the your information:

    Code:
    SELECT rating, restaurant FROM tablename
    You can also SELECT * FROM table... That just means select everything...

    You'll probably want to store each restaraunt's link in the database as well, but for now I'll show you how to simply output the ratings...

    Once you have that information you'll have to display it. To output you just loop through the results... here's an example:

    Code:
    $result = mysql_query("SELECT rating, restaurant FROM tablename");  
    
    // keeps getting the next row until there are no more to get
    while($row = mysql_fetch_array( $result )) {
    	echo $row['restaurant'].$row['rating'];
    }
    You can get an intro to retrieving data from mysql here.
    Have I helped you? You could help me.
    Like my business on facebook!
    Text message polls with real-time, live results.


Bookmarks

Posting Permissions

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