elite311 Posted January 6, 2012 Share Posted January 6, 2012 Hi, I've been working on making my own FAQ system for my site with PHP & MySQL, I have the SQL displaying properly on the page but I cant seem to figure out how to make it so when the page loads just the questions show and when a question is clicked the answer shows below it. I've read a number of tutorials and when I do get it to work it will only show the answer to the first question when the link is clicked. Here is the code I'm using to display the info from the database: <div id="faqSQL"> <?php foreach($result as $option) { ?> <div class="faq-question"><?php echo wordwrap($option['faqquestion'], 100, "\n", false);?></div> <div class="faq-answer"><?php echo wordwrap($option['faqanswer'], 100, "\n", false);?></div> <?php } ?> </div> If anyone can help it would be much appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/254460-collapsible-links/ Share on other sites More sharing options...
scootstah Posted January 6, 2012 Share Posted January 6, 2012 You need Javascript for this. Working example using jQuery here: http://jsfiddle.net/TxLxR/ Quote Link to comment https://forums.phpfreaks.com/topic/254460-collapsible-links/#findComment-1304717 Share on other sites More sharing options...
elite311 Posted January 6, 2012 Author Share Posted January 6, 2012 Thank you, got it to work great. I thought I could do this with PHP looks like I was looking in the wrong spot. Thanks again Quote Link to comment https://forums.phpfreaks.com/topic/254460-collapsible-links/#findComment-1304750 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.