process.php<?php $servername='localhost'; $username='root'; $password=''; $dbname = "trading"; $conn=mysqli_connect($servername,$username,$password,"$dbname"); if(!$conn){ die('Could not Connect My Sql:' .mysql_error()); } $query = mysqli_query($conn,"SELECT AVG(rating) as AVGRATE from rating_data where status=1"); $row = mysqli_fetch_array($query); $AVGRATE=$row['AVGRATE']; $query = mysqli_query($conn,"SELECT count(rating) as Total from rating_data where status=1"); $row = mysqli_fetch_array($query); $Total=$row['Total']; $query = mysqli_query($conn,"SELECT count(remark) as Totalreview from rating_data where status=1"); $row = mysqli_fetch_array($query); $Total_review=$row['Totalreview']; $review = mysqli_query($conn,"SELECT remark,rating,email from rating_data where status=1 order by date_time desc limit 4 "); $rating = mysqli_query($conn,"SELECT count(*) as Total,rating from rating_data group by rating order by rating desc"); ?> Show
index.php<?php include'process.php'; ?> <!DOCTYPE html> <html> <head> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"> <link rel="stylesheet" href="css/style.css"> <link rel='stylesheet' href='http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css'> <link rel='stylesheet' href='http://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css'> <link rel='stylesheet' href='https://raw.githubusercontent.com/kartik-v/bootstrap-star-rating/master/css/star-rating.min.css'> </head> <body> <div class="row container"> <div class="col-md-4 "> <h3><b>Rating & Reviews</b></h3> <div class="row"> <div class="col-md-6"> <h3 align="center"><b><?php echo round($AVGRATE,1);?></b> <i class="fa fa-star" data-rating="2" style="font-size:20px;color:#ff9f00;"></i></h3> <p><?=$Total;?> ratings and <?=$Total_review;?> reviews</p> </div> <div class="col-md-6"> <?php while($db_rating= mysqli_fetch_array($rating)){ ?> <h4 align="center"><?=$db_rating['rating'];?> <i class="fa fa-star" data-rating="2" style="font-size:20px;color:green;"></i> Total <?=$db_rating['Total'];?></h4> <?php } ?> </div> </div> <div class="row"> <div class="col-md-12"> <?php while($db_review= mysqli_fetch_array($review)){ ?> <h4><?=$db_review['rating'];?> <i class="fa fa-star" data-rating="2" style="font-size:20px;color:green;"></i> by <span style="font-size:14px;"><?=$db_review['email'];?></span></h4> <p><?=$db_review['remark'];?></p> <hr> <?php } ?> </div> </div> <div id="rating_div"> <div class="star-rating"> <span class="fa divya fa-star-o" data-rating="1" style="font-size:20px;"></span> <span class="fa fa-star-o" data-rating="2" style="font-size:20px;"></span> <span class="fa fa-star-o" data-rating="3" style="font-size:20px;"></span> <span class="fa fa-star-o" data-rating="4" style="font-size:20px;"></span> <span class="fa fa-star-o" data-rating="5" style="font-size:20px;"></span> <input type="hidden" name="whatever3" class="rating-value" value="1"> </div> </div> </div> </div><br> <input type="hidden" name="demo_id" id="demo_id" value="1"> <div class="col-md-4"> <input type="text" class="form-control" name="email" id="email" placeholder="Email Id"><br> <textarea class="form-control" rows="5" placeholder="Write your review here..." name="remark" id="remark" required></textarea><br> <p><button class="btn btn-default btn-sm btn-info" id="srr_rating">Submit</button></p> </div> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="js/index.js"></script> </body> </html>
PHP Review & Rating System using Ajax - Part 1PHP Review & Rating System using Ajax - Part 2
In this post, you can find How to create product or service review and star rating system with PHP & Mysql using Ajax jQuery. By using Review and Rating Module, user of your website will share their opinion and experiences which are related to your product or services. Review and Rating System is very important feature for get your user feedback regarding your product or services. With the help of review and star rating system, your user can rate your product or services by selecting star and write review about your product and services and with the help or this review and star rating service provider or product seller can improve their product or services. At the other hand at buyer side, because with the help of product or service rating and review, buyer can select quality product or services based on the rating and review provided by other customers. We can easily developed our own Rating and Review System with Mysql database using PHP with Ajax & jQuery. If you want to implement Review and Star Rating system for your product or services then this tutorial will help you to build review and 5 star rating system using PHP with Ajax jQuery and Mysql Database. In this tutorial, we will build Review and 5 star rating system for single product to demonstrate the functionality and user interface of Review and Rating System. Below you can find the feature of this PHP Dynamic Review and Rating System with Ajax jQuery.
Set Up Database TableFor build any dynamic system we need database and under database we need table. So first need to create database, so here we have already created testing for this tutorial and under this database for create review table, we have to run following .sql script for create review_table in Mysql Database. Review and Rating System Index PageFor build and Dynamic Review and Rating System, we have to first create layout for display Star Rating and Review data on web page. So in index.php we have to first create HTML code for display and Review and Rating content with Submit Rating and Review Data to the Server. So here in HTML code part, for display Rating data in Star icon we have use Font Awesome library and for Submit Review and Rating data we have use Bootstrap 4 modal dialog box. Below you can find HTML source code for create layout for display Rating and Review data on web page. index.php
Once we have create this html code, next we need to write jQuery for animate star icon, when we have mouse over or mouse leave from star icon. So in below jquery you can find how to animate star icon.
In this jQuery code, we have create one rating_data variable. Under this variable we will store user star rating data when user has click on any number of star icon. Next for submit Review and Rating data using bootstrap modal, we have use Ajax request, so when user click on submit button after fill review field, then star rating and review data will be send to PHP server script using Ajax request and this request will also received response from server also. Insert or Sve Review and Rating System DataOnce user has click on submit button then rating and reive data will be send to PHP script. So at PHP script first we need to make database connection. So below code you can see in which it will make Mysql database connection. submit_rating.php
After making database connection, then it will check $_POST["rating_data"] variable value has been set or not. IF this variable value is set then it will store review and rating data in simple array because here we will use PHP PDO class for insert data into database. And next we have write insert query and execute query for insert review and rating data into Mysql database and send response to Ajax request also. Fetch Review & Rating Data From DatabaseHere we have make dynamic Review and Rating System in PHP and Review and Rating data has been store under database. So once data has been store in database. Then we need to fetch from database and display on web page. So Here we have we have use Ajax jQuery for fetch data from database. For Fetch data we will make function which will send ajax request to PHP script and at server side php script will fetch data from database and return back data to Ajax request in JSON format. So once data has been received from server in JSON format then by using jQuery code it will display on web page. It will display both Star Rating and Review data on web page. Below you can find jQuery script and PHP script code for fetch data from database and display on web page without refresh of web page. index.php
submit_rating.php
If you want to get complete source with .sql file, so please write your email address in comment box. We will send you complete source code file at your define email address. How can I get star rating in PHP?Create PHP MySQL 5 Star Rating System with AJAX. Step 1: Create Database and Table.. Step 2: PHP MySQL Server Connection/li>. Step 3: Set Up jQuery Bar Rating Plugin.. Step 4: Display Star Rating and Average Rating.. Step 5: Implement 5 Star Rating in PHP.. How can make star rating in HTML and PHP?Step 1 – Start Apache Web Server.. Step 2 – Create PHP Project.. Step 3 – Create Table and Database Connection File.. Step 4 – Create Start Rating Html. Create Star Rating HMTL Markup. Integrate Star Rating jQuery Plugin. ... . Step 5 – Store Star Rating into Database.. Step 6 – Test This PHP App.. How can create review and rating page in PHP with AJAX?How to Create Review & Rating Page in PHP with Ajax. PHP Review & Rating System using Ajax - Part 1.. PHP Review & Rating System using Ajax - Part 2.. Set Up Database Table.. Review and Rating System Index Page.. Insert or Sve Review and Rating System Data.. Fetch Review & Rating Data From Database.. How do you create a star rating?Create a rating
Click on the title to give your rating a name. In the Rating Size box, you can select the size and color of the stars. If you'd like to use something other than stars, you can include the image URL in the box.
|