title: If exists, keep on looking, check again and repeat. Do while loop in PHP
body: <pre><code>$number = 1;
  do{
      $list_name = "Unnamed list ".$number;
  
      $list_name_exists = DB::select('name')-&gt;from('shoppinglists')-&gt;where('name', '=', $list_name)-&gt;execute()-&gt;count(); // returns 1 or 0
  
      $number++;
  }while($list_name_exists == 0);
  echo $list_name; // I want it here to output a name, that doesnt exists in the db.
  </code></pre>
  
  <p>What i tried to do above was to set $list_name, to a name that does not exists already in the db.</p>
  
  <p>But it does not seem to work, and page loads quite some time. </p>
  
  <p>How can i do this right?</p>