david_105 0 Newbie Poster

hi am having a dependant drop menu issue .
The menu part works fine but the submenu display data from all the table below are the codes plz what am i doing wrong

//MENU TEAM
$query = "SELECT u.id, u.nick, s.team_id, s.teams AS teams1, ss.team_id, ss.teams AS teams2, 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)
        LEFT JOIN " . $DBPrefix . "users u ON (u.id = b.bidder)
        LEFT JOIN " . $DBPrefix . "sports s ON (s.team_id = a.team1)
        LEFT JOIN " . $DBPrefix . "sports ss ON (ss.team_id = a.team2)
        WHERE b.auction = :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" id="menu">' . "\n";
if ($db->numrows() > 0){
        while ($row = $db->fetch())
        {
            $TPL_team_list .= "\t" . '
            <option value="' . $row[''] . '" ' . $selected . '>' . $row[''] . '</option>
            <option value="' . $row['team1'] . '" ' . $selected . '>' . $row['teams1'] . '</option>
            <option value="' . $row['team2'] . '" ' . $selected . '>' . $row['teams2'] . '</option>
            ' . "\n";
        }

        $TPL_team_list .= '</select>' . "\n";

{
    $template->assign_block_vars('tag_bidder', array(
    'TEAM' => $TPL_team_list,

            ));
    $i++;
}
}

?>
<script type="text/javascript" src="../js/dropdownjquery.js"></script>
<script type="text/javascript">
$(document).ready(function() {

    $("#menu").change(function() {
        $(this).after('<div id="loader"><img src="img/loading.gif" alt="loading subcategory" /></div>');
        $.get('loadsubcat.php?menu=' + $(this).val(), function(data) {
            $("#sub_cat").html(data);
            $('#loader').slideUp(200, function() {
                $(this).remove();
            });
        }); 
    });

});
</script>
    </select>
    <br/><br/><br/>

and loadsubcat.php

    <?php 
    include('../config.php');
    ini_set('display_errors',0);

    $menu = $_GET['menu'];
    $query = mysql_query("SELECT a.id, s.team_id, s.teams, u.nick, ut.nick_tag, b.id, b.willwin, b.willlose, b.bidder, b.tagged, b.bid, b.auction FROM vs_bids b 
    LEFT JOIN " . $DBPrefix . "vs_users u ON (u.id = b.bidder)
    LEFT JOIN " . $DBPrefix . "vs_users_tag ut ON (ut.id = b.tagged)
    LEFT JOIN " . $DBPrefix . "vs_auctions a ON (a.id = b.auction)
    LEFT JOIN " . $DBPrefix . "vs_sports s ON (s.team_id = b.willwin)
    WHERE willwin='$menu' and b.tagged != '0' order by b.tagged desc");

    while($row = mysql_fetch_array($query)) {
        echo "<option value=''></option>";
        echo "<option value='$row[team_id]'>$row[auction]...$row[nick]...$row[bid]...$row[teams]...$row[nick_tag]</option>";

    }

    ?>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.