title: Display data in a loop using laravel?
body: <p>I'm creating a simple analytics page for my website that shows data from my database.</p>
  
  <p>Part of the data looks like this:</p>
  
  <p><code>school ID: [ID here]</code> - <code>Inquiries: [number of inquiries here]</code>  <code>Applications: [Number of Applications here]</code></p>
  
  <p>the database table has multiple columns including <code>school_id</code> and <code>type</code>.</p>
  
  <p>This is my <strong>code</strong>:</p>
  
  <pre><code> $sql="SELECT * FROM school_attendants WHERE type='application' AND type='inquiry'";
                  $result=mysqli_query($con,$sql);
                  ?&gt;
  
                  @foreach($school_id as $school_id)
                      {{$school_id-&gt;school_id}} - Inquiries: {{$inquiries-&gt;count()}}  Applications: {{$applications-&gt;count()}}&lt;br/&gt;
                  @endforeach
  </code></pre>
  
  <p>It should basically go into the school_attendants table and find and display every school_id that is in there and count the number of times "application" and "inquiry" occur for a particular school_id.</p>
  
  <p>example: if school_id of 135 is in the table 20 times and 10 of those times has "application" in the type column and the other 10 times has "inquiry" in the type column, the code should display:</p>
  
  <p><code>school ID: 135</code>   <code>Inquiries: 10</code>  <code>Applications: 10</code></p>
  
  <p>then repeat for other school_id's it finds in the table.</p>
  
  <p>the error I am currently getting is:</p>
  
  <p><code>Undefined variable: school_id</code></p>