Php+mysql+ajax point like and the function of stepping

Source: Internet
Author: User
Too troublesome can also: click to download


Html:

 
  
 
   
      give force {ovov: $answer _datas.goods/}  
   
    do not give force {ovov: $answer _datas.bads/}   
 



HTML corresponding PHP file


 
  $value) {if ($value [' uid ']== $uid) {$zan _lists[]= $value [' answer_id '];} $smarty->assign (' zan_list ', $zan _lists); /Query The current login of the member's UID corresponding to the point like the answer/***** like the end ****//***** stepping start ****/$cai _list = Json_decode (Str_replace ("'", ' "', $cai _json), true); Cai_lists=array (); foreach ($cai _list as $key = + $value) {if ($value [' uid ']== $uid) {$cai _lists[]= $value [' answer_id '] ;}} $smarty->assign (' cai_list ', $cai _lists);//Query The UID of the currently logged-on member for the step answer/***** step over ****/$smarty->display (' own static page '); Exit (); break;}? >


Ajax files:

 ErrorMsg (' File error: shuzu/ovovsys_zan.php does not exist! '); exit ();} Converts the specified array to JSON data and converts the double quotation marks into single quotes, otherwise an error is placed in the array file----4$zan_new_json = Str_replace (' "'," ' ", Json_encode ($zan _array)); fp = @fopen ($config _path, ' r+ '), if (! $content = @fread ($fp, FileSize ($config _path)) {$Base->errormsg (' cannot read shuzu/ ovovsys_zan.php file Now! '); exit ();} Perform the substitution to----5$content = Str_replace ("\ $zan _json = \" {$zan _json}\ "", "\ $zan _json = \" {$zan _new_json}\ "" in the corresponding JSON data in the array file, $content); $fp = @fopen ($config _path, ' w+ '); @fwrite ($fp, $content); Modify the data in the corresponding data table----5$db->thisquery ("Update". $db _prefix. " Ask_answers ' Set ' goods ' = ' goods ' +1 where ' ans_id ' = '. $user _answer[' answer_id ']. ""); Exit (); break; Case ' CAI '://Stepping (not giving force) $cai _array = Json_decode (Str_replace ("'", ' "', $cai _json), true); $user _answer[' uid ']= $uid; $user _ answer[' answer_id ']=$_post[' answer_id ']; $cai _array[]= $user _answer; $config _path = ' shuzu/ovovsys_zan.php '; if (! File_exists ($config _path)) {$Base->errormsg (' File error: shuzu/ovovsys_zan.php does not exist! '); exit ();} $cai _new_json = str_replace (' "'," ' ", Json_encode ($cai _array)), $fp = @fopen ($config _path, ' r+ '), if (! $content = @fread ($fp, FileSize ($config _path))) {$Base->errormsg (' Unable to read shuzu/ovovsys_zan.php file! '); exit ();} $content = Str_replace ("\ $cai _json = \" {$cai _json}\ "", "\ $cai _json = \" {$cai _new_json}\ "", $content); $fp = @fopen ($ Config_path, ' w+ '); @fwrite ($fp, $content); $Db->thisquery ("Update". $db _prefix. " Ask_answers ' Set ' bads ' = ' bads '-1 where ' ans_id ' = '. $user _answer[' answer_id ']. ""); Exit (); break;}? >


The corresponding data file (since the creation of the database did not create a step and like the re-break, so here is the php file stored variables in the way to save the answer to the corresponding like and stepping data, which contains the user's ID and answer ID)

 
  You're right, that's two variables.

If the duplication of trouble, you can also click to download compressed files, Pro, do not point yo!
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.