radio button update from javascript to mysql -


i working on widget in zend framework , cannot radio button value update database. help. maybe sees dont.

thanks in advance.

here sample of radio html:

<div class="vote_block"> <form class="data_form">     <ul class="input_radio_group">     <li>         <input id="mediarating1" class="radiobtnclass" type="radio" title="poor" value=".1" name="rating">         <label class="label_radio">poor</label>         <div class="clear"></div>     </li>   </ul>   <button id="ratevotebutton" class="button"><span><?php echo $this->translator('send_button'); ?></span></button>   </form> 

i posted 1 radio button can idea of have.

here javascript on page:

<script type="text/javascript"> 

$(document).ready(function() {

$('#ratevotebutton').click(function() {         var rating = array();         $(this).parents('.rating_block').find('li input').each(function() {             if ($(this).attr('checked') == true) {                 rating.push($(this).attr('value'));         });         if (rating.length > 0) {             var data = $.tojson({                 'set_id': '<?php echo $this->set->set_id; ?>',                  'rating': '<?php # echo $this->rating; ?>'             });         }     } }); 

});

now widget page acts controller:

    protected function _prepareshow()  {     $setid  = $this->_request->getparam('set_id');     $rating = $this->_request->getparam('rating');      $conn = xxx_db_connection::factory()->getslaveconnection();     $setdao = xxx_model_dao_factory::getinstance()->setmodule('media')->getsetdao();     $setdao->setdbconnection($conn);      $data = zend_json::encode(array('set_id' => $setid, 'rating' => $rating));      $this->_view->assign('rating', $rating);     $this->_view->assign('data', $data); }  protected function _prepareresult()  {     $setid = $this->_request->getparam('set_id');     $rating = $this->_request->getparam('rating');      $conn = xxx_db_connection::factory()->getmasterconnection();     $setdao = xxx_model_dao_factory::getinstance()->setmodule('media')->getsetdao();     $setdao->setdbconnection($conn);       $setdao->increaserating($rating);         $data = zend_json::encode(array('set_id' => $setid, 'rating' => $rating));      $this->_view->assign('rating', $rating);     $this->_view->assign('data', $data); } 

last not least here sql statement:

    public function increaserating($rating) {     $sql = sprintf("update " . $this->_prefix . "media_set                     set rating = rating + '%s'                     set_id = '%s'",                     mysql_real_escape_string($rating->rating),                     mysql_real_escape_string($rating->set_id));     mysql_query($sql);     return mysql_affected_rows(); } 

when radio selected , hit button ?rating=.1 after link in address bar no update in database.

any suggestions help. again.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -