我有这个脚本,我应该在更改其值时更新数据。但是这段代码不起作用。我不知道它的问题是什么。
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>";
}
我希望有人可以帮助我。谢谢你!