title: If true use foreach loop, else use while
body: <p>I'm trying to link the MySQL while loop into foreach loop using something like this :</p>
  
  <pre><code>if($something == true){
    foreach($array as $arr){
  } else {
    while($row = mysql_fetch_array($mysql_query)){
  }
    // loop instructions
  }
  </code></pre>
  
  <p>It looks so wrong, I know but you see what I am trying to do ?.. I want to grab data from array if <code>$something</code> was true, else then grab data from database</p>
  
  <p>I had another solution idea and its to manually match the array with how <code>$mysql_query</code> works so I can use them both with <code>while</code> only, something like this :</p>
  
  <pre><code>if($something == true){
    $mysql_query = array("username" =&gt; "$_GET['username']", "password" =&gt; "$_GET['password']");
  } else {
    $mysql_query = mysql_query("SELECT * FROM users WHERE usern......");
  }
  
  while($row = mysql_fetch_array($mysql_query)){
  ...
  </code></pre>
  
  <p>That's a second way to do it but it looks wrong as well because the first array is normal, I want to match that normal array with how <code>mysql_query</code> builds it so it can fit with the while loop</p>
  
  <p><b>P.S. : I <b>DO NOT</b> want to repeat writing the loop instructions, I want them both to work with only one like I mentioned above</b></p>