SELECT COUNT for column in database?
<p>How to Count number of rows in a table that matches to the related condition and echo that count out.</p>

<p>Code goes as follows::</p>

<pre><code>&lt;?php 
     $sql = "SELECT * FROM input ORDER BY date DESC";
     $result = $conn-&gt;query($sql);

     if ($result-&gt;num_rows &gt; 0) { 
     while($row = $result-&gt;fetch_assoc()) { 
     $myid = $row["id"] ;
 $sql3 = "SELECT COUNT question_id FROM output WHERE question_id = $myid";
    $result3 = $conn-&gt;query($sql3);
?&gt;

&lt;div id="q"&gt;

        &lt;small&gt;&lt;p&gt;&lt;?php echo $row["date"]; ?&gt;&lt;/p&gt;&lt;/small&gt;
        &lt;p id="tag3"&gt;&lt;small&gt;&lt;?php echo $result3['']; ?&gt;&lt;/small&gt;&lt;/p&gt;
&lt;/div&gt;
</code></pre>

<p>Any Suggestions will be appreciated..</p>