doujinge9648 2015-09-01 09:11
浏览 5
已采纳

更新wordpress插件管理员中的表格列表

I have this script that should update the data when I change its value. But this code is not working. I dont know whats the problem with it.

function update_data(){
global $wpdb;
    if(isset($_POST['update'])) 
                {
                        $won = $_POST['won'];
                        $lost = $_POST['lost'];
                        $pct = $_POST['pct'];
                        $streak = $_POST['streak'];

                    $id = $wpdb->get_results("SELECT a.team_id, a.team_name, a.program_id ,b.games_won, b.games_lost, b.game_pct, b.winning_streak
                                FROM  program_teams as a
                                INNER JOIN program_team_standings as b
                                ON a.team_id=b.team_id");    
                    foreach ($id as $row) {
                         $id = $row->team_id;
                }
                $we = $wpdb->query("UPDATE program_team_standings
                            SET games_won = '$won',
                                games_lost ='$lost',
                                game_pct = '$pct',
                                winning_streak => '$streak'
                            WHERE team_id => '$id' ");                           
        echo "<script>alert('Team is now updated'); </script>";
}

I hope someone can help me.thank you!

  • 写回答

1条回答 默认 最新

  • doulin1867 2015-09-11 07:14
    关注

    Try This.

    Check in Your Query.

     $we = $wpdb->query("UPDATE program_team_standings
                                SET games_won = '".$won."',
                                    games_lost ='".$lost."',
                                    game_pct = '".$pct."',
                                    winning_streak => '".$streak."'
                                WHERE team_id => '".$id."' ");      
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序
  • ¥15 多址通信方式的抗噪声性能和系统容量对比