Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I don't know about cutting down on the HTML since I'm not aware of your specific needs, however, you can greatly simplify the PHP code with a HEREDOC. </p> <p>HEREDOC (<a href="http://us3.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc" rel="nofollow">PHP Manual HEREDOC</a>) is a method for outputting strings and outputting variables within as with double-quotes. The difference is that there is no need to escape any quotes within.</p> <p>Your code can use a HEREDOC like this:</p> <pre><code>$sql = "SELECT * FROM articles LIMIT $number"; $stmt = $pdo-&gt;query($sql); $stmt-&gt;setFetchMode(PDO::FETCH_ASSOC); while($row = $stmt-&gt;fetch()){ //Display the results formatted $dateTime = formatDateTime($row['datetime']) // functions cannot be used in HEREDOCS, so I replace it with the variable $dateTime declared here $content = &lt;&lt;&lt;HERE &lt;article class="igpPost"&gt; &lt;div class="igpPost-Divider"&gt;&lt;/div&gt; &lt;header&gt; &lt;h3&gt;&lt;a href="index.php?article="$row['id']"&gt;$row['title']&lt;/h3&gt; &lt;div class="igpPost-AuthTime"&gt;&lt;span&gt;Posted By: &lt;/span&gt;&lt;a href="#"&gt;$row['author']&lt;/a&gt; &lt;span&gt;at $dateTime&lt;/span&gt;&lt;/div&gt; &lt;div class="igpPost-AuthTime"&gt;&lt;span&gt;Tags: &lt;/span&gt; &lt;div class="igpPost-Img"&gt;&lt;img src="$row['imglocation']"/&gt;&lt;/div&gt; &lt;/header&gt; &lt;p&gt;$row['content']&lt;/p&gt; &lt;footer class="igpPost-Footer"&gt; &lt;div class="igpPost-ReadMore"&gt; &lt;h1&gt;&lt;a href="index.php?article="$row['id']"&gt;Read More..&lt;/a&gt;&lt;/h1&gt;&lt;/div&gt; &lt;/footer&gt; &lt;/article&gt; HERE; echo $content; } </code></pre>
    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. This table or related slice is empty.
    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