Jump to content

Recommended Posts

Ok here's the deal. My forum shows subforums on each category if there any, here is the code for that:

 

///-------------------------------
// Get The Subforums
//-------------------------------
$querysub = $DB->query("SELECT name, id, read_perms FROM ibf_forums WHERE parent_id = '{$forum_data['id']}' ORDER BY ibf_forums.position");
if($DB->get_num_rows($querysub) > 0) {
$subinfo = "<span class=desc><br>Subforums: ";
while($subin = $DB->fetch_row($querysub)) {
if ( $subin['read_perms'] != '*' ) {
if ( ! preg_match( "/(^|,)".$ibforums->member['mgroup']."(,|$)/", $subin['read_perms'] ) ) {
$subinfo .= "";
}
else if ( preg_match( "/(^|,)".$ibforums->member['mgroup']."(,|$)/", $subin['read_perms'] ) ) {
$subinfo .= "<a href='{$ibforums->base_url}showforum={$subin['id']}'>{$subin['name']}</a>, ";
}
}
else if ( $subin['read_perms'] == '*' ) {
$subinfo .= "<span class=desc><a href='index.php?showforum={$subin['id']}'>{$subin['name']}</a></span> - ";
}

}

$subinfo = substr ($subinfo, 0, -2);
}

 

Ok now, I want a user to beable to switch on and off by clicking 1 link to show those subforums and hide those subforums:

 

kinda like this picture:

 

29uwqpv.gif

 

 

Ok so your saying that it's a different question and im asking for help on a forum? Wrong :)

 

I have the link and the functions to use the link here:

 

In my Login.php there's this thing I added.

case '08':

    $this->showhidesubforums();

    break;

 

 

I did that so then When people click: forums/index.php?act=Login&CODE=08

 

It reads off this function showhidesubforums():

function showhidesubforums()
	{
		global $ibforums, $DB, $std, $_COOKIE;

		put my code in this spot so i can show/hide subforums


	$std->boink_it($ibforums->base_url);
	exit();
}  

 

 

Ok please please I am willing to stay with u and get help from u and obsorb your knowledge in.. but I need ur help (im french srry for language)

 

But yea, I need to put in a case switch php to show/hide the subforums code way above or what?

 

Please please guys, Help :)

 

 

Link to comment
https://forums.phpfreaks.com/topic/157770-toggle-view-with-php-case-switch-maybe/
Share on other sites

I have accomplished this in 2 ways. First, in my learning days, I would put a button on the form to force a page reload and then have the new form drawn. This is old school and not very efficient, although extremely effective. It can be frustrating for a user to have to wait for the page reload especially if a lot of db access is going on.

 

The second method is to use javascript and to manipulate div sections, essentially turning a div section on/off on the fly. This does not require a page reload and is extremely fast and effective.

 

Check the java script section for samples of this or pm me and I will supply an example of my crappy code.

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.