Mi expertise with WP coding is basic, almost reach intermediate level.

I know there must be a way to achieve this. I am using 2 loops one inside the other, to find matching values and save in DB.

Everything is working fine, but the index of first loop is displayed (so saved in DB) one pageload later than I expect.

And I can´t figure out why is this happening.

Please I need a hint,I´m not asking nobody to do it for me.

Here my code were:

$user_index is index grabed from DDBB
$_user_updat is associative array also grabed from DDBB
$this->sample_sec is array with secuence that must match with index of loop ($want)
$want is the index of first loop, which I need to save in DB

    if (isset($_POST['correcta'])) {
                echo "Correcta";
                $stop = false;
                for ($want=$user_index; $want < 127; $want++) { 
                    # recorremos todas las lecciones 
                    for ($went=0; $went < count($user_updat); $went++) { 
                        # Comprobacion      
                        if ($this->sample_sec[$want] == $user_updat[$went][1]) {        
                            echo "<p>Indice: ".$want."</p>";
                            // AQUI MOVEMOS LECCION DE CAJA 
                            echo $user_updat[$went][0]."en caja: ".$user_updat[$went][1];

                            maybe_serialize(update_user_meta( get_current_user_id(),'lmsleit_user_data',$user_updat));

                            $stop = true;
                        else{echo "Esta leccion no esta en la caja...";break;}
                        if($stop == true){
                            //maybe_serialize(update_user_meta( get_current_user_id(),'lms_index',$want));

                    if ($want == 126) {$want = 0;}


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.