Renlok Posted September 30, 2006 Share Posted September 30, 2006 heres what happens. theres a search bar you search for anything from the database and the search results are posted on the page.what i what to be able to happen is a viewer to be able to give a rating to the database entries and the current rating to be shown when there posted on the page.but i have no idea how to do this anyone have any ideas Link to comment https://forums.phpfreaks.com/topic/22603-how-could-i-make-a-rating-system-solved/ Share on other sites More sharing options...
wwfc_barmy_army Posted September 30, 2006 Share Posted September 30, 2006 There are a couple of rating tutorials around on the internet you could check out some of them. If you can't find a good one lemme know and i'll find the one i used.Peter. Link to comment https://forums.phpfreaks.com/topic/22603-how-could-i-make-a-rating-system-solved/#findComment-101487 Share on other sites More sharing options...
Orio Posted September 30, 2006 Share Posted September 30, 2006 http://www.google.com/search?hl=en&q=php+rating+systemToo many of them...Orio. Link to comment https://forums.phpfreaks.com/topic/22603-how-could-i-make-a-rating-system-solved/#findComment-101489 Share on other sites More sharing options...
Barand Posted September 30, 2006 Share Posted September 30, 2006 You are going to need a db table to hold the viewers ratings. ratings table-------------rating_iddatabase_item_idrating_valueThat's the minimum you need. Add a record each time someone rates a db item.(If you want safeguards to stop people rating an item several times then you are going to need to store something to identify the viewer too.)To get the rating for an item[code]SELECT AVG(rating_value) FROM ratings WHERE database_item_id = '$item_id'[/code] Link to comment https://forums.phpfreaks.com/topic/22603-how-could-i-make-a-rating-system-solved/#findComment-101532 Share on other sites More sharing options...
Renlok Posted October 4, 2006 Author Share Posted October 4, 2006 i have used you idea but my tables names are changes slightly here is my code i used[code]$URL = ($row['url']);$rate_query = "SELECT AVG(ratingValue) FROM rating WHERE URL = '$URL'";$rate_result = $db->query($rate_query);echo '<br><u>Rating:</u> '.$rate_result.'<br>';if ($rate_query == 0);{echo 'This entry has not yet been rated.';}[/code]but it will just show 'Object id #4' i dont know why Link to comment https://forums.phpfreaks.com/topic/22603-how-could-i-make-a-rating-system-solved/#findComment-103995 Share on other sites More sharing options...
Barand Posted October 4, 2006 Share Posted October 4, 2006 $rate_result is the recordset returned by the query. You need to get the first field from the first row of that recordset. Link to comment https://forums.phpfreaks.com/topic/22603-how-could-i-make-a-rating-system-solved/#findComment-103999 Share on other sites More sharing options...
Renlok Posted October 5, 2006 Author Share Posted October 5, 2006 and how would i go around doing that?lol im new to this Link to comment https://forums.phpfreaks.com/topic/22603-how-could-i-make-a-rating-system-solved/#findComment-104185 Share on other sites More sharing options...
Renlok Posted October 5, 2006 Author Share Posted October 5, 2006 anyone? Link to comment https://forums.phpfreaks.com/topic/22603-how-could-i-make-a-rating-system-solved/#findComment-104279 Share on other sites More sharing options...
Barand Posted October 5, 2006 Share Posted October 5, 2006 I don't jnow what class you are using.If it's mysqli, then[code]$row = $db->fetch_row();$rate_result = $row[0];[/code] Link to comment https://forums.phpfreaks.com/topic/22603-how-could-i-make-a-rating-system-solved/#findComment-104374 Share on other sites More sharing options...
Renlok Posted October 5, 2006 Author Share Posted October 5, 2006 [code]$URL = ($row['url']); //url is primary key in main database$rate_query = "SELECT AVG(ratingValue) FROM rating WHERE URL = '$URL'";$row = $db->fetch_row();$rate_result = $row[0];echo '<br><u>Rating:</u> '.$rate_result.'<br>';if ($rate_query == 0);{echo 'This entry has not yet been rated.';}[/code]Fatal error: Call to undefined method mysqli::fetch_row() in /home/renlok/public_html/results.php on line 74 Link to comment https://forums.phpfreaks.com/topic/22603-how-could-i-make-a-rating-system-solved/#findComment-104406 Share on other sites More sharing options...
Renlok Posted October 6, 2006 Author Share Posted October 6, 2006 [code]$URL = ($row['url']);$rate_query = "SELECT ratingValue FROM rating WHERE URL = '$URL'";$rate_result = $db->query($rate_query);$num_results = $rate_result->num_rows;$avg = +$rate_result/$num_results;echo '<br><u>Rating:</u> '.$avg.'<br>';if ($rate_query == 0);{echo 'This entry has not yet been rated.';}[/code]this is my most resent attempt also not working will show rating as 1 no matter what the actual rating is it also always shows 'This entry has not yet been rated.' Link to comment https://forums.phpfreaks.com/topic/22603-how-could-i-make-a-rating-system-solved/#findComment-104826 Share on other sites More sharing options...
Barand Posted October 6, 2006 Share Posted October 6, 2006 [code]<?php$rate_result = $db->query($rate_query);$row = $rate_result->fetch_row();$avg = $row[0];?>[/code] Link to comment https://forums.phpfreaks.com/topic/22603-how-could-i-make-a-rating-system-solved/#findComment-104834 Share on other sites More sharing options...
Renlok Posted October 6, 2006 Author Share Posted October 6, 2006 thanks for all the help it now works. Link to comment https://forums.phpfreaks.com/topic/22603-how-could-i-make-a-rating-system-solved/#findComment-105066 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.