Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Change SQL so you don't get two columns with the same name</p> <pre><code>SELECT subjects.name, exam_type.name, result.mark FROM subjects --&gt; SELECT subjects.name, exam_type.name as test, result.mark FROM subjects </code></pre> <p>Then you can do something like this (I've simulated the result from the db)</p> <pre><code>$result = array( 0 =&gt; array( 'name' =&gt; 'Agricultural Science', 'test' =&gt; 'CA 1', 'mark' =&gt; 10 ), 1 =&gt; array( 'name' =&gt; 'Agricultural Science', 'test' =&gt; 'CA 2', 'mark' =&gt; 9 ), 2 =&gt; array( 'name' =&gt; 'Agricultural Science', 'test' =&gt; 'CA 3', 'mark' =&gt; 8 ), 3 =&gt; array( 'name' =&gt; 'Agricultural Science', 'test' =&gt; 'Exam', 'mark' =&gt; 56 ), 4 =&gt; array( 'name' =&gt; 'English Language', 'test' =&gt; 'CA 1', 'mark' =&gt; 12 ), 5 =&gt; array( 'name' =&gt; 'English Language', 'test' =&gt; 'CA 2', 'mark' =&gt; 13 ), 6 =&gt; array( 'name' =&gt; 'English Language', 'test' =&gt; 'CA 3', 'mark' =&gt; 12 ), 7 =&gt; array( 'name' =&gt; 'English Language', 'test' =&gt; 'Exam', 'mark' =&gt; 43 ) ); $data = array(); foreach ($result as $row) { $data[$row['name']]['marks'][$row['test']] = $row['mark']; } ?&gt; CA test | Exams&lt;br /&gt; &lt;?php foreach ($data as $name =&gt; $row) { echo $name . ' | ' . $row['marks']['CA 1'] . ' | ' . $row['marks']['CA 2'] . ' | ' . $row['marks']['CA 3'] . ' | ' . $row['marks']['Exam'] . '&lt;br /&gt;'; } </code></pre> <p>Output</p> <pre><code>CA test | Exams Agricultural Science | 10 | 9 | 8 | 56 English Language | 12 | 13 | 12 | 43 </code></pre> <p>Then just add it to however you generate tables.</p>
    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.
 

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