Still submenu issue

Have a read of post #6.

To summarise, to pass the auction id to the script that populates the submenu, it needs to be somewhere in the page. So you output a div containing the value, which you can style to not appear on the page if you don’t want it to. Then you get the value of it and pass it through as well as the menu value.

You ought to think about these variable names and parameter names - calling something menu when it’s actually a bidder id doesn’t make things clear to read for an outsider, or you in five years time when you come back to change something.

so how do i go about making both submit like the lower code plus the values are used by the query to make the menu swap so i cant changed them else the swap wont work

from a novice to a prof no clue what to do here n that

and how do i make the first code work like the lower code i cant change the value number query needs it for the drop menu swap to work, am trying both codes when one works will move on from there

I think half the trouble here is that you’re jumping around making massive changes, swapping to entirely new ways of doing things, rather than just going step by step eliminating problems. That’s why back in post #12 I said you should just have the submenu code display the two parameters so you know that bit is working, then add the query back and go from there.

I don’t really know how the latest code you’ve posted works - you seem to have some stuff like {TEAM1} that suggests a template system, where before you were just using standard PHP. I don’t know anything about template systems.

You said earlier, after I talked about passing the second parameter to the submenu code

and I wanted to see that code - where you’d added the stuff that I talked about in post #6 to pass the auction id. Without that, your submenu query won’t be able to select based on that parameter.

heres where i implemented the stuff

$query = "SELECT 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 . "sports s ON (s.team_id = a.team1)
        LEFT JOIN " . $DBPrefix . "sports ss ON (ss.team_id = a.team2)
        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);
?>

<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="images/loading.gif" alt="loading subcategory" /></div>');
        var auction = $("#auctionid").text();  
 $.get('loadsubcat.php?menu=' + $(this).val() + "&auc=" + auction, function(data) {
            $("#sub_cat").html(data);
            $('#loader').slideUp(200, function() {
                $(this).remove();
            });
        });    
    });

});
</script>
<form name="bid">
    <label for="category">Select Winner</label>
    <select name="willwin" id="menu">
    
    <?php
if ($db->numrows() > 0){
        while ($row = $db->fetch()) { ?>
        <option value=''></option>
        
        <option value="<?php echo $row["team1"]; ?>"><?php echo $row["teams1"]; ?></option>
        <option value="<?php echo $row["team2"]; ?>"><?php echo $row["teams2"]; ?></option>
        <?php 
}
}
?>
    </select>
    <br/><br/><br/>
  
    <label>Tag Bettor</label>
    <select name="sub_cat" id="sub_cat"></select>
</form>

and the loadsubcat.php

<?php 
include('config.php');

$menu = $_GET['menu'];
$query = "SELECT a.id, s.team_id, s.teams, u.nick, b.id, b.willwin, b.willlose, b.bidder, b.auction FROM vs_bids b 
LEFT JOIN " . $DBPrefix . "vs_users u ON (u.id = b.bidder)
LEFT JOIN " . $DBPrefix . "vs_auctions a ON (a.id = b.auction)
LEFT JOIN " . $DBPrefix . "vs_sports s ON (s.team_id = b.willwin)
WHERE willlose='$menu'";

while ($row = $db->fetch()) {
    echo "<option value=''></option>";
    echo "<option value='$row[team_id]'>$row[auction]...$row[nick]...$row[teams]</option>";
    echo '<div id="auctionid">' . $id . '</div>';
    
}
?>

not sure if done right way or over done the right way

and here am using a template base system thats what the tpl code is all about.

But you haven’t done this bit:

and you haven’t done this bit:

and without those, it won’t work.

plz how do i do those once?

Well, the echo is pretty self-explanatory, and to get the auc parameter in the submenu code, just copy the line where you retrieve the menu value and change the names.

i really dont wanna be guessing or assuming if i knew wherw to start would have replied with the codes already

and thanks alot u been really helpful

I’m not suggesting you guess or assume anything. I wrote out the echo line, you just need to insert that in your main code wherever it is suitable from a html point of view. And again, surely copying a line of code and changing some variable names cannot be much of an issue? But that’s really where I was saying to do one thing at a time, so you can measure the effect of it.

I hope you don’t take this the wrong way, but on principal I won’t just write the code for you. I could (probably) edit your two bits of code, make them work and that would be that, but (a) you won’t learn anything from it, and (b) this is your project, not mine. I don’t know if you’re doing it for fun, or because it’s your job, or because you want to be the next Zuckerberg, but whichever it is, it’s your project. I’m happy to do what I can, to the extent of my time and ability, to help solve individual issues, but I won’t just do it for you.

I don’t know what your background is, or how much knowledge you have. A lot of the code you’ve posted is quite complex code, it’s not beginner stuff, so I’d presumed that you had written it, hence adding an echo here or grabbing a variable value there shouldn’t matter.

1 Like

thanks issue is was into programmer but drop it for years cause of my masters and things started to look new to me am just catching on now thays y i ask a lot of questions, beside i can only place the div in the loadsubcat page cause am using a template

You can’t put the div in the script that loads the subcategory because you don’t know the value there. The whole point of the div is to have the auction id value somewhere in the main page so it can be used to pass the value to the other script.

so i decided for now to do things a bit manual i wrote this code to check if a user is selecting the same team as the bidder they are tagging to return error

$query = "SELECT willwin FROM " . $DBPrefix . "bids WHERE bidder = :tagged and auction = :auc_id and willwin = :willwin";
$params[] = array(':tagged', $bidder, 'int');
$params[] = array(':auc_id', $id, 'int');
$params[] = array(':willwin' , $willwin, 'int');

not want i want fully but still get the job done

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.