Menu
Forums
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Trending
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
Upgrades
Log in
Register
What's new
Search
Search
Search titles only
By:
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Software Development
Programming
PHP echo rows in table
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="oxuwazet" data-source="post: 453094" data-attributes="member: 88455"><p>[CODE=php]<?php</p><p></p><p>// the number of results.</p><p>$noof = 19;</p><p></p><p>// the number of results in a row.</p><p>$ross = 6;</p><p></p><p>$i = 0;</p><p>for ($ii = 0; $ii < $noof; $ii++) {</p><p> $i++;</p><p> echo "{RESULT}";</p><p> if ($i % $ross == 0) {</p><p> echo "<br />";</p><p> }</p><p>}</p><p></p><p>?></p><p>[/CODE]</p><p></p><p>This will result in:</p><p></p><p>{RESULT}{RESULT}{RESULT}{RESULT}{RESULT}{RESULT}</p><p>{RESULT}{RESULT}{RESULT}{RESULT}{RESULT}{RESULT}</p><p>{RESULT}{RESULT}{RESULT}{RESULT}{RESULT}{RESULT}</p><p>{RESULT}</p><p></p><p>For tables:</p><p></p><p>[CODE=php]<?php</p><p></p><p>// the number of results.</p><p>$noof = 19;</p><p></p><p>// the number of results in a row.</p><p>$ross = 6;</p><p></p><p>// start tables logic.</p><p></p><p>echo "<tr>\n";</p><p>$i = 0;</p><p>for ($ii = 0; $ii < $noof; $ii++) {</p><p> $i++;</p><p> echo "<td>{RESULT}</td>\n";</p><p> if ($i % $ross == 0) {</p><p> echo "</tr>\n";</p><p> if (!($noof - 1 < $ii)) {</p><p> echo "<tr>\n";</p><p> }</p><p> }</p><p>}</p><p>if (!($i % $ross == 0)) {</p><p> echo "</tr>\n";</p><p>}</p><p></p><p>// end tables logic.</p><p></p><p>?>[/CODE]</p><p></p><p>This will result in:</p><p></p><p>[CODE=html]<tr></p><p><td>{RESULT}</td></p><p><td>{RESULT}</td></p><p><td>{RESULT}</td></p><p><td>{RESULT}</td></p><p><td>{RESULT}</td></p><p><td>{RESULT}</td></p><p></tr></p><p><tr></p><p><td>{RESULT}</td></p><p><td>{RESULT}</td></p><p><td>{RESULT}</td></p><p><td>{RESULT}</td></p><p><td>{RESULT}</td></p><p><td>{RESULT}</td></p><p></tr></p><p><tr></p><p><td>{RESULT}</td></p><p><td>{RESULT}</td></p><p><td>{RESULT}</td></p><p><td>{RESULT}</td></p><p><td>{RESULT}</td></p><p><td>{RESULT}</td></p><p></tr></p><p><tr></p><p><td>{RESULT}</td></p><p></tr>[/CODE]</p><p></p><p>If you have further questions please ask.</p></blockquote><p></p>
[QUOTE="oxuwazet, post: 453094, member: 88455"] [CODE=php]<?php // the number of results. $noof = 19; // the number of results in a row. $ross = 6; $i = 0; for ($ii = 0; $ii < $noof; $ii++) { $i++; echo "{RESULT}"; if ($i % $ross == 0) { echo "<br />"; } } ?> [/CODE] This will result in: {RESULT}{RESULT}{RESULT}{RESULT}{RESULT}{RESULT} {RESULT}{RESULT}{RESULT}{RESULT}{RESULT}{RESULT} {RESULT}{RESULT}{RESULT}{RESULT}{RESULT}{RESULT} {RESULT} For tables: [CODE=php]<?php // the number of results. $noof = 19; // the number of results in a row. $ross = 6; // start tables logic. echo "<tr>\n"; $i = 0; for ($ii = 0; $ii < $noof; $ii++) { $i++; echo "<td>{RESULT}</td>\n"; if ($i % $ross == 0) { echo "</tr>\n"; if (!($noof - 1 < $ii)) { echo "<tr>\n"; } } } if (!($i % $ross == 0)) { echo "</tr>\n"; } // end tables logic. ?>[/CODE] This will result in: [CODE=html]<tr> <td>{RESULT}</td> <td>{RESULT}</td> <td>{RESULT}</td> <td>{RESULT}</td> <td>{RESULT}</td> <td>{RESULT}</td> </tr> <tr> <td>{RESULT}</td> <td>{RESULT}</td> <td>{RESULT}</td> <td>{RESULT}</td> <td>{RESULT}</td> <td>{RESULT}</td> </tr> <tr> <td>{RESULT}</td> <td>{RESULT}</td> <td>{RESULT}</td> <td>{RESULT}</td> <td>{RESULT}</td> <td>{RESULT}</td> </tr> <tr> <td>{RESULT}</td> </tr>[/CODE] If you have further questions please ask. [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Software Development
Programming
PHP echo rows in table
Top