Today, We want to share with you Simple PHP Rating System with database using JavaScript.
In this post we will show you Star-Rating System, hear for PHP Star Rating System with JavaScript we will give you demo and example for implement.
In this post, we will learn about Building a 5 Star Rating System With jQuery, AJAX and PHP with an example.
Simple PHP Rating System with database using JavaScript
There are the Following The simple About Simple PHP Rating System with database using JavaScript Full Information With Example and source code.what makes a restaurant 5 star?
Database Script for Star Rating
Make statements as well as the data facke for the tbl_hotel_review and tbl_hotels tables.
-- -- Table structure for table `tbl_hotel_review` -- CREATE TABLE `tbl_hotel_review` ( `id` int(11) NOT NULL, `member_id` int(11) NOT NULL DEFAULT '1', `hotel_id` int(11) NOT NULL, `review` int(2) NOT NULL, `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- -- -- Table structure for table `tbl_hotels` -- CREATE TABLE `tbl_hotels` ( `id` int(11) NOT NULL, `name` varchar(100) NOT NULL, `address` varchar(150) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `tbl_hotels` -- INSERT INTO `tbl_hotels` (`id`, `name`, `address`) VALUES (1, '9 old sungan classic ploat new', '12, pakainfo Enclave'), (2, 'newar infinityknow web dola', '78, PAKA Park'); -- -- Indexes for dumped tables -- -- -- Indexes for table `tbl_hotel_review` -- ALTER TABLE `tbl_hotel_review` ADD PRIMARY KEY (`id`); -- -- Indexes for table `tbl_hotels` -- ALTER TABLE `tbl_hotels` ADD PRIMARY KEY (`id`); -- -- AUTO_INCREMENT for dumped tables -- -- -- AUTO_INCREMENT for table `tbl_hotel_review` -- ALTER TABLE `tbl_hotel_review` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=13; -- -- AUTO_INCREMENT for table `tbl_hotels` -- ALTER TABLE `tbl_hotels` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3; COMMIT;
List Restaurants with Star Rating Option
5 Star Rating System using simple PHP MySQLi and Javascript
fetchReviewData.php
This PHP servser side source code is called with jQuery an AJAX request to response the restaurant list with user review data. It simple dynamic forms HTML results that will be fetched at the jQuery AJAX success simple callback.
' . $row['name'] . '
- ';
for ($count = 1; $count <= 5; $count ++) {
$starRatingId = $row['id'] . '_' . $count;
if ($count <= $memberReview) {
$outputString .= '
- ★ '; } else { $outputString .= '
- ★ '; } } // endFor $outputString .= '
Total Reviews: ' . $totalRating . '
' . $row["address"] . '