Jump to content

animated collapse with variables


doddsey_65

Recommended Posts

Im working with the animatedcollapse.js file which collapses divs. I need to collapse divs with the id's 1,2,3,4. Simple enough.

 

However they wont always be 1,2,3,4 as these are the ids (forum_id) pulled from the database. the animatedcollapse.js script requires the names of the divs to be entered like so:

 

<a href=\"javascript:animatedcollapse.show(['1','2','3','4'])\">

 

but like i said it won't always be 1,2,3,4 so how can i pull the id's and add them to that href? i was thinking an array but ive never worked with them before so i cant get it to work.

 

I need to pull all of the forum_id's where parent_id = 1 and then add the id's to the href.

Link to comment
https://forums.phpfreaks.com/topic/216366-animated-collapse-with-variables/
Share on other sites

If I understand correctly something like this might work.

$sql = "SELECT `forum_id` FROM `forums` WHERE `parent_id` = 1";
$sql_query = mysql_query($sql);
$ids = array();
while ($data = mysql_fetch_assoc($sql_query)) {
$ids[] = $data['forum_id'];
}
if (!empty($ids)) {
echo '<a href="javascript:animatedcollapse.show([\''.join("','",$ids).'\'])">';
} 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.