Jump to content

Adding a dependant sub menu


skyhigh

Recommended Posts

hi guys this is my first post here and i need assistance with this, i have menu code and a sub code seperate i need to make them as 1.

thats menu with a submenu, below is my code for menu

$query = "SELECT a.id, a.team1, a.team2, b.auction, b.bidder, b.tagged, b.willwin, b.willlose FROM " . $DBPrefix . "auctions a    LEFT JOIN " . $DBPrefix . "bids b ON (b.auction = a.id)    WHERE a.id = :auc_id and a.id = a.id group by a.id";    $params = array();    $params[] = array(':auc_id', $id, 'int');    $db->query($query, $params);    $TPL_team_list = '<select name="willwin" class="form-control">' . "\n";    while ($row = $db->fetch())    {        $TPL_team_list .= "\t" . '        <option value="' . $row[''] . '" ' . $selected . '>' . $row[''] . '</option>        <option class="team1" value="' . $row['team1'] . '" ' . $selected . '>' . $row['team1'] . '</option>        <option class="team2" value="' . $row['team2'] . '" ' . $selected . '>' . $row['team2'] . '</option>        ' . "\n";    }    $TPL_team_list .= '</select>' . "\n";{$template->assign_block_vars('tag_bidder', array('TEAM' => $TPL_team_list,        ));$i++;}

and below is my submenu

$query = "SELECT b.*, u.nick, u.rate_sum FROM " . $DBPrefix . "bids bLEFT JOIN " . $DBPrefix . "users u ON (u.id = b.bidder)WHERE b.bidder NOT IN ('b.tagged') and b.tagged IN ('b.bidder')     and         b.auction = :auc_id order by b.willwin";$params = array();$params[] = array(':auc_id', $id, 'int');$db->query($query, $params);    $TPL_team_list = '<select name="tagged" class="form-control">' . "\n";    while ($row = $db->fetch())    {        $TPL_team_list .= "\t" . '        <option value="' . $row[''] . '" ' . $selected . '>' . $row[''] . '</option>        <option value="' . $row['bidder'] . '" ' . $selected . '>' . $row['nick'] . '...' . $row['willwin'] . '</option>        ' . "\n";    }    $TPL_team_list .= '</select>' . "\n";{$template->assign_block_vars('tag_bidder', array('NAME' => $TPL_team_list,        ));$i++;}

how do i make the menu dependent. what i mean is if i select a menu that will determine what will drop down, thanks

 

Link to comment
Share on other sites

how do i make the menu dependent. what i mean is if i select a menu that will determine what will drop down, thanks

 

Ask yourself where the main and sub menus are generated.  Up in the cloud or on your server, right?  Now ask yourself where you select the first menu which will determine the second menu.  From the client computer you are sitting directly in front of, right?  Your server only knows what it is given, and will always execute script from start to finish and then quit until another request is made from the client.  The client requests the html to generate the menus, the server provides it, and the client displays it, and then the transaction id done.  If the main or sub menu is changed, this entire process is repeated.  You can either request all the required html each time (client sends server the currently selected main menu and the newly clicked sub menu), or do so via ajax and just request what you need.

Link to comment
Share on other sites

no idea what u just wrote

 

Make sure you fully understand that the content on the client and the content on the server are totally different.  If you understand this, you will understand that your server only serves content specifically based on the clients request.

 

You can do what you are asking many ways.  I assume you want to just tweak the code you posted.  Both the main menu and submenu use $selected.  Note that these are two totally different variables, but you didn't post all your code so no one can really tell you how they are set.  Also $row[''] is definitely wrong.

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.