Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to show answer respective to its ID from database once the ID is clicked?
    primarykey
    data
    text
    <p>This is a FAQ page. I am currently having problem to show the answer with its respective question. The page is able to show all the questions in the database as I have already placed them in the loop. However ,when I clicked on any questions to view the answer. It will only collapse the first question and the show answer that appears first in my database. I want it to collapse and show the answer with respective to its question when I clicked on the different questions. How should I go about doing it?</p> <p>Below is my code: </p> <pre><code>&lt;h1&gt;FAQ&lt;/h1&gt; &lt;?php $result = mysql_query("SELECT * FROM faq where status='Enabled' ORDER BY id ASC;"); if($result &gt;= 1 ){ echo '&lt;hr class="colorgraph"&gt;'; $i=1; while ($row = mysql_fetch_assoc($result)) { $id = $row["id"]; ?&gt; &lt;div class="panel-group" id="accordion"&gt; //this is dropdown box. &lt;div class="panel panel-default"&gt; &lt;div class="panel-heading"&gt; &lt;h4 class="panel-title"&gt;&lt;a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion" href="#collapseOne"&gt; &lt;?= $row['question'] ?&gt;&lt;/h4&gt; &lt;/a&gt;&lt;/div&gt; // the user has to click this to dropdown to see the information below &lt;div id="collapseOne" class="panel-collapse collapse"&gt; &lt;div class="panel-body"&gt;&lt;?= $row['answer'] ?&gt;&lt;/div&gt; // this is the information that will be shown once it dropped down &lt;/div&gt; &lt;/div&gt; </code></pre> <p></p> <pre><code> &lt;?php $i++; } }else{ echo "No Questions Found&lt;br&gt;&lt;/table&gt;"; } ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
 

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