0

i got a little problem with my code. I need to reset my fetch but i can't find a way to do it. Thanks in advance and sorry if i have make some error, English is not my first language.

Here is my code :

while($donnees=$req->fetch()){

    echo 'compare :' . $donnees[0] . '</br>';

    while($donnees2=$req2->fetch()){

        echo $donnees2[0];

        if($donnees[0]==$donnees2[0]){
            echo '/ ok /' . '</br>';
        }
        else {
            echo '/ not ok /'  . '</br>';
        }
    }

result

treyBake
  • 6,440
  • 6
  • 26
  • 57
  • By "resest" you mean you want to go back to the first row? To be honest you might be better to do fetchAll on $req2 outside the loop and put it into an array, which you can then loop as many times as you like. – ADyson Jan 20 '20 at 11:17
  • where exactly you want to reset/break your fetch? what is the desired result? – mitkosoft Jan 20 '20 at 11:17
  • Show us your proper code. Only seeing while, we can't tell you anything. – Amanjot Kaur Jan 20 '20 at 11:23
  • Thank for tou help, I resolve my problem. – lvl_lile Jan 21 '20 at 08:42
  • while ($don=$req->fetch()){ echo ' la salle : ' . $don[0] .''; $req2=$bdd->query("SELECT classLib FROM `classroom`"); while($don2=$req2->fetch()){ echo ' est comparer a :' . $don2[0] . ' il est :'; if($don[0]==$don2[0]){ echo 'compatible' . ''; } else{ echo 'aucune classe trouver dans la bdd' . '';; } } } – lvl_lile Jan 21 '20 at 08:42

0 Answers0