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
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).'\'])">';
} 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.