php - Trying to send star ratings from krajee bootstrap star rating to mysql database -


i using following plugin

http://plugins.krajee.com/star-rating

i'm trying send rating submitted database values not being recorded.

require_once $doc_root . '/includes/act_initiate_article_xref.php';      $rating_value = (@$user_article_xref_row['rating'] > 0) ? $user_article_xref_row['rating'] . ' stars' : 'unrated';     $article_rating = '<span class="line-sep">rated:</span> ' . $rating_value; if ($_session['user_id'] == 1 || $_session['user_id'] == 41)    {     $rating_value_attr = (isset ($user_article_xref_row['rating'])) ? ' value="' . $user_article_xref_row['rating'] . '"' : '';     $article_rating .= '<span class="line-sep">your rating: </span> <input id="input-21d" type="number" class="rating"' . $rating_value_attr . ' data-min=0 data-max=5 step=0.5 data-size="xs">'; } 

and code act_initiate_article_xref.php

<?  /**  * reads user_article_xref  */ $this_routine[] = "includes/act_initiate_article_xref.php";  /**  * no direct access allowed  */ $doc_root = $_server['document_root']; require_once $doc_root . '/includes/act_check_valid_access.php';  $table_title = 'user_article_xref';  $user_id = (isset ($_session['user_id'])) ? $_session['user_id'] : 0;  $fields = '`id`, `hits`, `rating`'; $match_where = '`user_id` = ' . $user_id . ' , `article_id` = ' . $article_id; $article_result = $db->selectbystrings($fields, $table_title, $match_where, null, 1); #if ($_session['user_id'] == 1) { echo "<br>21. select $fields $table_title $match_where<pre>";print_r($_session);echo "</pre>"; }  /**  * if there record, update  * if there isn't record, insert  * either way, $user_article_xref_row holds details ajax rating update  */ if ($db->getnumrows($article_result) > 0)   {     $user_article_xref_row = $db->getnextrow($article_result);     $hits = $user_article_xref_row['hits'] + 1;     $pairs_array = array ('hits' => $hits);     $id_where = '`id` = ' . $user_article_xref_row['id'];     $update_result = $db->updatebyarray($table_title, $pairs_array, $id_where);     $test = 'update'; } else {     $hits = 1;     $user_article_xref_row = array ('user_id' => $user_id, 'article_id' => $article_id, 'hits' => $hits);     $insert_result = $db->insertbyarray($table_title, $user_article_xref_row);     $test = 'insert'; } #if ($_session['user_id'] == 1) { echo "<br>37. $test<pre>";print_r($user_article_xref_row);echo "</pre>"; }  ?> 

i know post little old in case. in star-rating.js added ajax post php file set.listenclick function. hope helps.

self.listenclick(self.$rating, function(e) {                 if (self.inactive) {                     return false;                 }                 pos = self.getposition(e);                 var div_id = self.$element.attr('id');                 self.setstars(pos);                 self.$element.trigger('change').trigger('rating.change', [self.$element.val(), self.$caption.html()]);                 self.starclicked = true;                 var rating = self.$element.val();                 $.ajax({                 type:"post",                 url:"rating.php",                 data:"div="+div_id+"&rating="+rating,                 success: function(res){                  console.log("rating posted " + div_id + rating);                                              return res;                 }             });             }); 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -