Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>Are there other methods for outputting an HTML table that are faster than my WHILE loop?</p> </blockquote> <p>Potentially yes. PHP is a templating language. Use it as such, don't fight it! Native templating is likely to be faster than laboriously sticking strings together manually — and IMO more readable.</p> <pre><code>&lt;table&gt; &lt;?php foreach($results as $result) { ?&gt; &lt;tr&gt; &lt;td&gt;&lt;?php echo htmlspecialchars($result[0]); ?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo htmlspecialchars($result[1]); ?&gt;&lt;/td&gt; &lt;/tr&gt; &lt;?php } ?&gt; &lt;/table&gt; </code></pre> <p>(Note the use of <code>htmlspecialchars</code>. If you don't use this function <em>every time</em> you insert plain text into HTML, your code has HTML-injection flaws, leading to potential cross-site-scripting vulnerabilities. You can define a function with a short name like <code>h</code> to do <code>echo htmlspecialchars</code> to avoid some typing, but you <em>must</em> HTML-encode your strings.)</p> <p>However: whilst this is prettier and more secure, it is unlikely to be significantly faster in practice. Your client-side rendering slowness is almost certainly going to be caused more by:</p> <ol> <li><p>network transmission speeds for a lot of table data. You can improve this by deploying with <code>zlib.output_compression</code>, <code>mod_deflate</code> or other compressing filter for your web server, if you have not already.</p></li> <li><p>rendering speeds for large tables. You can improve this by setting the CSS style <code>table-layout: fixed</code> on your <code>&lt;table&gt;</code> element and adding <code>&lt;col&gt;</code> elements with explicit <code>width</code> styles for the columns you want to have a fixed width.</p></li> </ol>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

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