title: Replace goto into while loop?
body: <p>I am using <code>goto</code> if there is any error and it would start again at the top.</p>
  
  <p>I also can't use <code>goto</code> in the function to jump outside of the function.</p>
  
  <p>I know <code>goto</code> is bad but how would <code>while</code> loop would fit into my code?</p>
  
  <p>For example:</p>
  
  <pre><code>$ch = curl_init();
  
  retry:
  
  $result = curlPost($ch, "home.php", http_build_query($arg));
  
  if (strpos($postResult, "Welcome") !== false) {
      sleep(10);
      goto retry;
  }
  
  $sql = "SELECT * FROM data";
  $q = mysql_query($sql) or die(mysql_error());
  
  while($row =  mysql_fetch_assoc($q)) {
      $name['something'] = $row['name'];
      submitData($ch,$name);
  }
  
  
  function submitData($ch,$name) {
  
      $result2 = curlPost($ch, "submit.php", http_build_query($name));
  
      if (strpos($postResult, "Website close") !== false) {
          sleep(10);
          goto retry; //goto wouldnt work.
      }
  
     // do something here
  }
  </code></pre>