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!
Try This.
Check in Your Query.