title: how to run foreach loop with ternary condition
body: <p>i have two foreach loop to display some data, 
  but i want to use a single foreach on basis of database result.</p>
  
  <p>means if there is any row  returns from database then 
  <code>forach($first as $fk=&gt;$fv)</code> should execute otherwise 
  <code>foreach($other as $ok)</code> should execute.
  i m unsing below ternary operator which gives parse error</p>
  
  <pre><code>$n=$db-&gt;numRows($taskData); // databsse results
  
  &lt;?php ($n) ? foreach ($first as $fk=&gt;$fv) : foreach ($other as $ok) 
  { ?&gt;
  &lt;table&gt;&lt;tr&gt;&lt;td&gt;......some data...&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
  &lt;?php } ?&gt;
  </code></pre>
  
  <p>please suggest me how to handle such condition via ternary operator or any other idea.</p>
  
  <p>Thanks</p>