Ajax call isn't update my rows

后端 未结 1 1033
后悔当初
后悔当初 2021-01-28 10:10

I want to update my database with the ids of characters, but when I drop them into the slot, it doesn\'t update the rows I want it to update. My question is can you point me in

相关标签:
1条回答
  • 2021-01-28 10:46

    Since you are sending a csv with a the key of i, you need to get your values from $_POST['i'] by exploding on the ,. So your code could be updated to something like-

    //Update the user team.
    if (isset($_POST['f']) && $_POST['f'] == 'updateTeam')  {
    
    //Explode the i post
    if (isset($_POST['i'])) { 
            $vals = explode("," , $_POST['i'] );
        }
    
    if (isset($vals[0])) {
            $cid1 = $secure->clean($vals[0]);
        } else {
            $cid1 = '1';
        }
    
    if (isset($vals[1])) {
            $cid2 = $secure->clean($vals[1]);
        } else {
            $cid2 = '2';
        }
    
    if (isset($vals[2])) {
            $cid1 = $secure->clean($vals[2]);
        } else {
            $cid1 = '3';
        }
    
    $updateTeam = $db->query("UPDATE accounts SET cid1 = '$cid1', cid2 = '$cid2', cid3 = '$cid3' WHERE id = '$id'");
    }
    
    0 讨论(0)
提交回复
热议问题