Jump to content

skyhighweb

Members
  • Posts

    86
  • Joined

  • Last visited

Posts posted by skyhighweb

  1. i don't understand the question (updated) oh yeah seen it, have changed it, but still effect i still get full datas from the menu side

  2. 36 minutes ago, dsonesuk said:

    The array is treated as tables, the value from first dropdown is used to show other related info from related array/table info.

    The way the second dropdown is processed can be placed in another php file, which is called by using ajax.

    This is a rough guide on how to send info from first to second dropdown, the principle is the same, I did not reproduce the effect using your code, as you seem to want us to do it for you, as you keep saying  you tried this and that! But! don't actually show us what code you tried, just the repeated showing of the same code.

    
    <!DOCTYPE html>
    <!--
    To change this license header, choose License Headers in Project Properties.
    To change this template file, choose Tools | Templates
    and open the template in the editor.
    -->
    <html>
        <head>
            <meta charset="UTF-8">
            <title></title>
        </head>
        <body>
            <?php
            if (isset($_POST['willwin'])) {
                $teamRec = $_POST['willwin'];
            }
    
    
            $team_array = [];
            $team_array['Team1'] = ['Team #1 dropdown1', 'Team #1 dropdown2', 'Team #1 dropdown3', 'Team #1 dropdown4'];
            $team_array['Team2'] = ['Team #2 dropdown1', 'Team #2 dropdown2', 'Team #2 dropdown3', 'Team #2 dropdown4'];
            ?>
    
            <form id="myform" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>">
                <select name="willwin" class="form-control">
                    <option value="">Select Team </option>
                    <?php
                    $optioncount = 0;
                    foreach ($team_array as $key => $value) {
                        $optioncount++;
                        if ($key === $teamRec) {
                            echo '<option class="team' . $optioncount . '" value="' . $key . '" selected="selected">Team #' . $optioncount . '</option>';
                        } else {
                            echo '<option class="team' . $optioncount . '" value="' . $key . '">Team #' . $optioncount . '</option>';
                        }
                    }
                    ?>
    
    
                    <!--<option class="team1" value="Team1">Team #1</option>
                    <option class="team2" value="Team2">Team #2</option>-->
    
                </select><br>
                <?php
                if (isset($_POST['willwin'])) {
    
    
                    echo '<select name="tagged" class="form-control">';
                    echo '<option value="">Select Team Info </option>';
                    $team_array_item = $team_array[$teamRec];
    
                    foreach ($team_array_item as $key => $value) {
                        echo '<option value="' . $value . '">' . $value . '</option>';
                    }
                    echo '</select><br>';
                }
                ?>
    
    
                <input type="submit">
            </form>
    
    
        </body>
    </html>

     

    i have been trying, for example have been working on the below code it doing what i want but problem with it is it displays all data in a table instead of whats been viewed at the moment

    <?php
    require_once('conn.php');
    ini_set('display_errors',0);
    
    $query = "SELECT b.auction, b.bidder, b.tagged, b.willwin, b.willlose, a.id, a.team1, a.team2  FROM " . $DBPrefix . "vs_auctions a
    LEFT JOIN " . $DBPrefix . "vs_bids b ON (b.auction = a.id) 
    LEFT JOIN " . $DBPrefix . "vs_sports s ON (s.team_id = b.id) 
    WHERE a.id = b.auction and a.id = a.id group by b.auction";
    $country_result = $conn->query($query);
    
    ?>
    
    
    <select name="country" id="vs_sports-list" onchange="changeSelect( this.value )">
    <option value="1">Select Team</option>
    <?php
    if ($country_result->num_rows > 0) {
    // output data of each row
    while($row = $country_result->fetch_assoc()) {
    ?>
    <option value="<?php echo $row["willwin"]; ?>"><?php echo $row["team1"]; ?></option>
    <option value="<?php echo $row["willlose"]; ?>"><?php echo $row["team2"]; ?></option>
    <?php
    }
    }
    ?>
    </select>
    </br></br></br><div id="subcats">
    <select name="bidder" id="vs_bids-list">
    <option value='1'>Select Number</option>
    
    </select></div>
    <?php
    
    $willlose = mysql_real_escape_string($_POST['willlose']);
    if($willlose!='')
    {
    
    
    $vs_bids_result = $conn->query('select b.auction, b.bidder, b.tagged, b.willwin, b.willlose from vs_bids b where willlose='.$willlose.' ');
    $options = "<option value=''>Select Name</option>";
    while($row = $vs_bids_result->fetch_assoc()) {
    $options .= "<option value='".$row['id']."'>".$row['bidder']."</option>";
    }
    echo $options;
    }
    
    ?>
    
    <script src="js/dropdown/jquery-1.3.0.min.js"></script>
    
    <script>
    $('#vs_sports-list').on('change', function(){
    var willlose = this.value;
    $.ajax({
    type: "POST",
    data:'willlose='+willlose,
    success: function(result){
    $("#vs_bids-list").html(result);
    }
    });
    });
    
    </script>
    
    

    in my existing code i am using this

    $query = "SELECT a.id, a.team1, a.team2, b.auction, b.bidder, b.tagged, b.willwin 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);

    thats display only what been viewed at the moment

  3. 9 hours ago, dsonesuk said:

    When the form is submitted,OR the select dropdown triggers a onchange event that uses AJAX, it should pass the value of selection using $_POST[] or $_GET to the second dropdown.

    It usually uses this value to filter and access the related records, but I currently do not see any fields that would possibly do that? All I see is filtering by 'auc_id', is this relative value passed through by team1 or team2?

    hi, i am no where near a submenu drop down linked to menu, all i have is  a field for the menu and a field for the submenu seperately, auc_id is used to display only data being viewed at the moment.

  4. 13 minutes ago, justsomeguy said:

    Do you know how to get the value of the first dropdown?  You can either submit it regularly with a form, or get it with Javascript and send it with ajax.  I've already asked you these questions though, you seemed to indicate that you know how to get the value from the form.  If you don't, you need to hit the PHP tutorials to learn the basics.

    i can get the first value wwith a form but getting the sub menu is the issue for me else would have done that,  just look tru for me n assist me, that wwill b great thanks, either JavaScript or ajax cant seem to get it to connect.

  5. hello programmers again really need your help with this, i Need a menu linked to a sub menu

    i have a menu code and a submenu code but they arent linked, both i select manually, so i need help linking both of them.
    the menu consist of two values team1 and team2 i want when i select team1 it should drop down a menu of users who selected team1 and vice versa.

    for the MENU we got two tables they are

    auctions: with column: id             team1      team2  
    bids:       with column: auction     bidder      willwin


    and for the sub menu we also have two tables
    bids     with:  column: auction     bidder      willwin
    users  with:  column:  nick

     

    MENU CODE

    // MENU team select
    		$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++;
    }

    SUBMENU CODE   

    // SUBMENU user name
            $query = "SELECT b.*, u.nick, u.rate_sum FROM " . $DBPrefix . "bids b
    LEFT 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++;
    }


    really looking forward to ur help thanks.

  6. 13 hours ago, justsomeguy said:

    I'm not sure what else to say.  You have code to create a dropdown already based on information in the database.  You've said that you know how to get data from a form.  So, get the data from the form for the parent dropdown, and use it to get the data from the database and build the child dropdown almost exactly like the code you showed in the first post.

    If you're just copying and pasting code without understanding how it works, then that's the problem.  If that's the case you need to start with the PHP tutorials to learn how this stuff works before expecting that you'll be able to change or add to it.

    i am trying something hopefully that works also posted a issue about it

  7. hi how do i rewrite this

     

    $country_result = $conn->query('select * from sports');

    and this

     

    $bids_result = $conn->query('select * from bids where willwin='.$willwin.'');
    $options = "<option value=''>Select Name</option>";
    while($row = $bids_result->fetch_assoc()) {
    $options .= "<option value='".$row['id']."'>".$row['bidder']."</option>";

    to work like this

     

      $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);
      thanks
  8. 4 hours ago, justsomeguy said:

    So get the submitted value, and use it to look up whatever database records correspond to that, and build the other dropdown.  I'm not sure what you're missing.  If you know how to process a form, and you know how to use the database, and you know how to build a dropdown, which part are you having problems with?

    hi am having problem on the drop down part if i knew what to do i would have stopped posting questions n do it

  9. 11 hours ago, justsomeguy said:

    Do you know how to get form data?  That would be the first step to getting the options for the second dropdown.  If you don't know how to do that, I would suggest starting with some of the beginning PHP tutorials.  Getting data from a form is one of the more basic things you should understand.

    hi jsg thanks for ur reply, have been over it again n again cant even seem to get it to work, please help me out with it, i will b glad n have a good nite sleep today, thanks

  10. 19 minutes ago, justsomeguy said:

    Well, there's 2 options I mentioned.  Either have a normal form submit where you get the parent value and use it to build the child dropdown with PHP, or get the parent value with Javascript and send it to the server using ajax to get the list of options for the child dropdown.

    i totally understand wwhat u saying my friend but i just dont know how to start about it thats y i posted the menu code am using, can u plz take a look at it for me n help out, will b grate ful

  11. 6 minutes ago, justsomeguy said:

     

     

    I don't know what that means.

    If you're trying to make dropdowns which depend on other dropdowns, the basic way to do that is to have the form submit when you pick from the parent list, PHP gets the submitted value for that list, and writes out the child list based on the parent value.  You could also use ajax to submit the value to the server and have it return the options for the child list, then update the page with that.

    yeah am trying to make a dropdown that depends on other drop down but no idea how to go about it

  12. hi programmers how u doing? i need help creating a sub menu but with a twist

    MENU
    Submenu- team1 on click will display dropdown list of team2 lists
    team2 on click will display dropdown list of team1 lists

    if a user select (team1) it should drop down list of [team2] and if the user select (team2) it should drop list of [team1].

    the code below is only a menu without submenu need ur assistance, thanks alot

     

    // team select
    		$query = "SELECT a.id, a.team1, a.team2, b.auction, b.bidder, b.tagged, b.willwin 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 value="' . $row['team1'] . '" ' . $selected . '>' . $row['team1'] . '</option>
    			<option 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++;
    }

    Tables : auctions

    columns: id(int), team1, team2
    3 chelsea ajax

    Tables : bids
    columns: auction(int) bidder willwin
    3 9 chelsea
    3 5 ajax
    3 7 chelsea
    3 2 ajax
    3 6 chelsea
    3 4 chelsea

  13. am having a duplicate result because of bids.
    i need to limit the result for only auctions to 1, i tried "limit 1" but they all get limited to 1 both bids n auctions, how do i limit only auctions to 1
    how do i go about this, thanks.

     

    $query = "SELECT b.*, u.nick, a.id, a.team1, a.team2 FROM " . $DBPrefix . "bids b
    LEFT JOIN " . $DBPrefix . "users u ON (u.id = b.bidder)
    LEFT JOIN " . $DBPrefix . "auctions a ON (a.id = b.auction)
    WHERE b.bidder NOT IN ('b.tagged') and b.tagged IN ('b.bidder') and b.auction = :auc_id";
    $params = array();
    $params[] = array(':auc_id', $id, 'int');
    $db->query($query, $params);
  14. On 05/05/2017 at 7:34 PM, justsomeguy said:

     

    
    WHERE bidder NOT IN ('tagged') and tagged IN ('bidder')

     

    That's going to select every record where the word "tagged" is not in the bidder column, and the word "bidder" is in the tagged column.  I don't think you're looking for the words "tagged" and "bidder".  If you want the values in those columns then you select them like I showed.

    As for the result you showed above, that's not correct.  I created a table and inserted the 4 rows you showed with exactly the same data, and I ran the same query, and it did not select rows where the value in bidder is in the tagged column.  It did not select all 4 of those rows, it only selected the 2 with a 0 in the tagged column.  So if it's not working for you, then you're not doing it right.  Just understand what that query is doing, it's not hard to understand.  That's all you need.

    yeap i changed the name from buyer to bidder n implemented the not in code it working fine now, thanks alot

×
×
  • Create New...