Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I think I see what may be causing the problem.</p> <p>For every sixth item returned from <code>oyunSayisi()</code>, you want to create a table row that shows the data from <code>oyunCek()</code>. The problem is that the first modulus just outputs <code>&lt;tr&gt;</code>, then <em>every</em> line runs the <code>foreach</code> loop. Finally, the second modulus outputs <code>&lt;/tr&gt;</code>. I think you want to combine everything into just one modulus, like this:</p> <pre><code>for($i = 0; $i &lt; $db-&gt;oyunSayisi(); $i++) { if ($i % 6 == 0) { echo "&lt;tr&gt;&lt;br/&gt;\n"; foreach($db-&gt;oyunCek() as $oyun) { ?&gt; &lt;td width="224" height="115"&gt;&lt;a href="&lt;?=$db-&gt;siteAdres()?&gt;/oyun.php?id=&lt;?=$oyun['o_id']?&gt;" title="&lt;?=$oyun['o_baslik']?&gt; oyna"&gt;&lt;img height="115;110" src="&lt;?=$db-&gt;siteAdres()?&gt;/resimler/&lt;?=$oyun['o_resim']?&gt;" title="&lt;?=$oyun['o_baslik']?&gt; oyna" alt="&lt;?=$oyun['o_baslik']?&gt; oyna" /&gt;&lt;/a&gt;&lt;/td&gt; &lt;?php } echo "&lt;/tr&gt;\n"; } } </code></pre> <p><strong>EDIT:</strong></p> <p>Upon further pondering, it did not make sense that you would want to only echo every sixth line of data... so it occurred to me that you are probably trying to create a new table row every sixth line, rather than skipping any of the inner <code>foreach</code> loops. Here is the modified code to do that:</p> <pre><code>echo "&lt;tr&gt;\n"; for($i = 0; $i &lt; $db-&gt;oyunSayisi(); $i++) { foreach($db-&gt;oyunCek() as $oyun) { ?&gt; &lt;td width="224" height="115"&gt;&lt;a href="&lt;?=$db-&gt;siteAdres()?&gt;/oyun.php?id=&lt;?=$oyun['o_id']?&gt;" title="&lt;?=$oyun['o_baslik']?&gt; oyna"&gt;&lt;img height="115;110" src="&lt;?=$db-&gt;siteAdres()?&gt;/resimler/&lt;?=$oyun['o_resim']?&gt;" title="&lt;?=$oyun['o_baslik']?&gt; oyna" alt="&lt;?=$oyun['o_baslik']?&gt; oyna" /&gt;&lt;/a&gt;&lt;/td&gt; &lt;?php } if (($i + 1) % 6 == 0) { echo "&lt;/tr&gt;\n&lt;tr&gt;\n"; } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload