Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1007
  • Last Modified:

jquery accordion populate headings with records

hi all please can any one help.

i have this accordion jQuery

http://jqueryui.com/demos/accordion/ 

i am looking to try and populate the headings with a result from a php query.

the thing is i need to know how to automatically add new headings to the accordion if lots of results are  found by my php database query.

hope i have explained well. thx for any comments.  
0
helpchrisplz
Asked:
helpchrisplz
  • 4
  • 2
1 Solution
 
PragmatiCoderCommented:
Is the content of the accordion static (hard coded) or dynamic (an AJAX response per se)?
0
 
helpchrisplzAuthor Commented:
i have a online games league. am letting players create a war / appointment. and on each clan profile this accordion will show the date, name of clans as the heading in the accordion then if the user clicks the heading it will expand and show more information about the league match appointment.

need to add more headings to the accordion if there are loads of upcoming league wars / appointments booked in.
0
 
helpchrisplzAuthor Commented:
so depending on the amount of records produced by the while loop i need to count them and have that as the number of headings in the accordion and then populate each heading with each record
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
PragmatiCoderCommented:
Ok, i think i got the idea here...

This is based on the basic functionality demo
(http://jqueryui.com/demos/accordion/default.html)
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<title>jQuery UI Accordion - Default functionality</title>
	<link rel="stylesheet" href="../../themes/base/jquery.ui.all.css">
	<script src="../../jquery-1.6.2.js"></script>
	<script src="../../ui/jquery.ui.core.js"></script>
	<script src="../../ui/jquery.ui.widget.js"></script>

	<script src="../../ui/jquery.ui.accordion.js"></script>
	<link rel="stylesheet" href="../demos.css">
	<script>
	$(function() {
            $( "#accordion" ).accordion();
	});
	</script>
</head>
<body>

    
<div class="demo">

<div id="accordion">
    <?php 
        $query = "SELECT heading, content FROM table WHERE 1";
        $result = mysql_query($query);
        while($row = mysql_fetch_object($result)){
    ?>
	<h3><a href="#"><?php echo $row->heading;?></a></h3>
	<div>
		<p>
		<?php echo $row->content; ?>
		</p>
	</div>
    <?php } ?>
</div>

</div><!-- End demo -->
</body>
</html>

Open in new window

0
 
helpchrisplzAuthor Commented:
ahh looks so simple i understand now. i will test tomorrow as its 3:37 AM here  
0
 
helpchrisplzAuthor Commented:
thx
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now