Note that there are some explanatory texts on larger screens.

plurals
  1. POcreating a list with database values
    primarykey
    data
    text
    <p>I am trying to print a list something like this....</p> <blockquote> <pre><code>Catagory 01 subjects1 subjects4 subjects2 subjects5 subjects3 subjects6 Catagory 02 subjects1 subjects4 subjects2 subjects5 subjects3 subjects6 Catagory 03 subjects1 subjects4 subjects2 subjects5 subjects3 subjects6 </code></pre> </blockquote> <p>One category has its own subjects. At the moment I have the category id and created a query to get its category name and its owned subjects. this is the query that I have created..</p> <pre><code>$categoryIds = implode(',', $_SESSION['category']); $q = "SELECT c. category_id AS ci, c.category_name AS cn, s.subject_name AS sn, s.subject_id AS si FROM category AS c INNER JOIN category_subjects AS cs ON cs.category_id = c.category_id INNER JOIN subjects AS s ON s.subject_id = cs.subject_id WHERE c.category_id IN ($categoryIds)"; $r = mysqli_query( $dbc, $q) ; </code></pre> <p>Above query gives every categories and it own subjects. Its like a multidimensional array. My problem is I tried to print this date something like above list... But can not get it to work..</p> <p>$catID = false;</p> <p>while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)) {</p> <pre><code>echo '&lt;div&gt;'; if ( $catID != $row['ci']) { echo '&lt;h3&gt;Category 01: &lt;span&gt;' . $row['cn'] . '&lt;/span&gt;&lt;span&gt;&lt;/span&gt;&lt;/h3&gt;'; } echo '&lt;div class="container"&gt;'; echo '&lt;p&gt;' . $row['sn']. '&lt;/p&gt;'; // This subjects I need to display in a table with 2 columns.. $catID = $row['ci']; echo '&lt;/div&gt;'; echo '&lt;/div&gt;'; </code></pre> <p>}</p> <p>Is there someone to help me to this? Your ideas and comments are greatly appreciated. </p> <p>Thank you. </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.
    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