Jump to content
  • Announcements

    • boen_robot

      Guidelines and Netiquette   03/28/2017

      Posting Problems:   Having problems posting your topic? Read through this: To join, you agree to our terms and conditions and fill out and submit a registration form. An activation email will be sent to your email adress, so you'll need to verify your account. After that the account has to be validated by one of the moderators. This will mean that it can take up to a day to be activated. A couple of things to remember to ensure approval: Don't use an email address in one of those $2 four character .com domains eg. xyds.com. These will be deleted and the domain added to the banned list. Don't use an email address that is within a domain with a bad reputation for spam. A Google search is run on every email address and email domain. Don't sign up with an email address that doesn't exist, doesn't work or requires the sender to answer a quiz before their email can get to you. Put your country and or state and city in the signup form. Blank forms will go to the botton of the "to do" list. And make sure that your email address and your country match, saying you're from Alabama and using a .ru email address is not going to get you activated. After a membership is activated the first few posts will be monitored. Posting spam or unapproved topics described in the agreement results in an immediate ban. The email provider and the IP addresses associated with the account will be banned and all posts will be deleted. These strict measures have been deemed necessary to hinder spam. Sorry for any inconvenience this causes, but it's not liable to change. If, after reading this, you still can't post and don't understand why, contact one of the Moderators listed here.   Topic Guidelines   Including the following information can expedite an accurate response from board members: Must be a Specific Problem or Question related to web design and development Include Code in Question (wrap with   for small blocks of code and for longer blocks   ) Include Code Author Include Extra Notes/Modifications/Attempts Include web link to page/file when possible Content Guidelines   You may not post, upload, link to, or email any Content that contains, promotes, gives instruction about, or provides prohibited Content. Prohibited Content includes any Content that breaks any local, state, county, national or international law. Prohibited Content also includes: No direct or indirect advertising or websites, forums, products, services No hijacking of posts (do not post your question in someone elses) Content that infringes upon any rights [ex. MP3s and ROMs] (including, but not limited to, copyrights and trademarks) Abusive, threatening, defamatory, racist, or obscene Viruses or any other harmful computer software False Information or libel Spam, chain letters, or Pyramid schemes Gambling or Illicit drugs Terrorism Hacking or cheating for internet/online games Warez, Roms, CD-Keys, Cracks, Passwords, or Serial Numbers Pornography, nudity, or sexual material of any kind Excessive profanity Invasive of privacy or impersonation of any person/entity Hacking materials or information Posting Tips   There are more BBcodes than there are buttons for on the reply menu. To get the full list, click "BB Code Help" underneath the clickable smilie face menu. Use   for small snippets of code Use   for lengthy snippets of code Use   if your snippet is HTML (optional) Use   if your snippet is SQL (optional) Rules of Conduct   Be nice. There's no need for calling someone stupid if they ask an 'easy' question. Keep your avatars and signatures absolutely child friendly. We have a younger audience on this forum. Keep your language appropriate for the same reason above. Do not PM moderators for help on the forum. Post on the topic, or create a new one.   Spam:   Recently, as you have all without doubt noticed, we have had lots of spam and advertisement on the forum. Therefore, we'd like to alert you as to what to do when you have found any of the aforementioned annoying messages: it. Immediately. Give a clear reason, please, if the advertising is not evident. DO NOT POST! Report, let the post stay as is, and we will get to it, meanwhile if you continue to post as normal in the other threads, it won't be on the top so long. Refrain from PMing the member. This won't help at all, as they are most likely spambots anyway. Thank you.       Images in signatures:   After thinking of users on dial-up, we have decided to enforce the following rules regarding signatures. Please pay heed to them. Respecting these rules is respecting the members on this forum with dial-up. Signature rules: No animated images AT ALL. No matter the amount of animation. Maximum image widthxheight: 300x150 Maximum image (file) size: 15kb Use calm colors. Do not use highly contrasting images in your signature, as this can get really annoying when seeing several posts from one member in the same thread. The same prohibited content goes for images as for posts. Lastly, use common sense. No lengthy signatures please. Save us some scrolling. Thank you.       Links in signatures:   Please understand that w3schools.com only exists because of voluntary work and is barely supported by the advertising littered throughout the tutorials and the forum. So, please, stop advertising other sites. DO not post links that drive traffic away from the w3schools domain - especially to a site that offers similar if not identical information. Please help support the site by keeping individuals on it. Thank you. Here are some guidelines as to what you can put in your signature: w3schools links --> allowed w3.org links --> allowed browser links --> allowed html editor links --> allowed personal sites --> allowed tutorial sites competing with w3schools --> NOT allowed sites completely irrelevant to webprogramming and this forum --> NOT allowed   Thanks for understanding, and for taking the time to read this. ~W3Schools Modstaff~
skyhighweb

php drop down sub menu

Recommended Posts

dsonesuk    712

Should it not be

where b.willlose='.$willlose.' '

And does the values in 'willose' column have a space after the value as shown by using 

.' '

on the search value?

Share this post


Link to post
Share on other sites
skyhighweb    0

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

Edited by skyhighweb

Share this post


Link to post
Share on other sites
skyhighweb    0
35 minutes ago, dsonesuk said:

Should it not be


where b.willlose='.$willlose.' '

And does the values in 'willose' column have a space after the value as shown by using 


.' '

on the search value?

yeah checked i remove all the b. i wasnt even joining anything, if only i could try rewrite this

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) 
WHERE a.id = b.auction and a.id = a.id group by b.auction";

$country_result = $conn->query($query);

so it will look 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);

so i can stay connected to my database with this config file

<?php
$DbHost	 = "localhost";
$DbDatabase = "vsb";
$DbUser	 = "root";
$DbPassword = "pass";
$DBPrefix	= "vs_";
$main_path = "D:\\xampp\\htdocs\\vsbet\\";
$MD5_PREFIX = "ca801ec4f5c664bc6a492f942b3a07eb";
?>

that way i can simply intergrate the code smoothly , because right now it like am having two seperate connection acting differently

Share this post


Link to post
Share on other sites
dsonesuk    712

IF $db represent connection to database, what is $conn?

You just require single variable connection to a single database.

For each select statement attached to $query variable you call

$db->query($query);

directly following it and process the results following that.

IF you manually insert a value instead of a variable, does it produce correct result, if it does not then the select query is faulty.

Share this post


Link to post
Share on other sites
skyhighweb    0
4 minutes ago, dsonesuk said:

IF $db represent connection to database, what is $conn?

You just require single variable connection to a single database.

For each select statement attached to $query variable you call

$db->query($query);

directly following it and process the results following that.

IF you manually insert a value instead of a variable, does it produce correct result, if it does not then the select query is faulty.

it produces the correct result, the problem now is the script am using as u can see is different from what have been using, have tried changing things around so the script can connect to a db and not conn i have two seperate connection, db is the one have been using while conn is the one that came along with the drop menu code

Share this post


Link to post
Share on other sites
dsonesuk    712

Then I dont understand?, if you insert manually the correct value in SQL statement, it works but! if the value returned by $_POST is the same as the manually entered value it does not, that just does not make sense.

Share this post


Link to post
Share on other sites
skyhighweb    0
11 minutes ago, dsonesuk said:

Then I dont understand?, if you insert manually the correct value in SQL statement, it works but! if the value returned by $_POST is the same as the manually entered value it does not, that just does not make sense.


no i meant, using the previous form field, i can insert values into the table using $db without the drop down values which i iinsert maunaly from the database backend into the row, but with the $conn i can only view those values along side the drop down values. u know what is there a way i can message u the script so u see for ur self along side what am trying to do?

 

Share this post


Link to post
Share on other sites
dsonesuk    712

I do not know WHAT you want now? you said you want the sub dropdown to show data from database depending what is passed back from parent dropdown, it may or may not work? then you talk about inserting? then you find a script that uses $conn?

Maybe you should learn to understand MYSQL, PHP, SQL first! Instead of just finding any script that may/nearly produces the required results. and pasting into your own, and then get us to unravel third party code for you, which unrelated to your current code.

Message me! well sorry, that's not going to happen.

Share this post


Link to post
Share on other sites
skyhighweb    0

ok so after checking em am finally getting close i have them connected to one database and converted them from conn to db, the menu works fine but the sub menu disappears when i select a menu, the code below plz chk for me what am doing wrong thanks, i might not have converted all or missing a code or something

$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);

?>


<select name="country" id="sports-list" onchange="changeSelect( this.value )">
<option value="1">Select Team</option>
<?php
if ($db->numrows() > 0) {
// output data of each row
while ($row = $db->fetch()) {
?>
<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="bids-list">
<option value='1'>Select Number</option>

</select></div>
<?php
$willlose = mysqli_real_escape_string($_POST['willlose']);
if($willlose!='')
{


$query = "SELECT b.*, u.nick, u.rate_sum FROM " . $DBPrefix . "bids b 
LEFT JOIN " . $DBPrefix . "users u ON (u.id = b.bidder)
WHERE willlose=".$willlose." and 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);


$options = "<option value=''>Select Name</option>";
while ($row = $db->fetch()) {
$options .= "<option value='".$row['auction']."'>".$row['nick']."</option>";
}
echo $options;
}

?>

<script src="js/dropdown/jquery-1.3.0.min.js"></script>

<script>
$('#sports-list').on('change', function(){
var willlose = this.value;
$.ajax({
type: "POST",
data:'willlose='+willlose,
success: function(result){
$("#bids-list").html(result);
}
});
});

</script>

 

Share this post


Link to post
Share on other sites
justsomeguy    954

You're not printing any of those options into the select list.

This is the problem with not understanding the code you are working with.  We are here to help people learn how to program.  We expect people to start on their own, and make an effort.  If you're not going to go through the tutorials to learn the basics about how this stuff works, how can we help you?  Just doing everything for you does not teach you anything except that when you have a problem you come here to get the answer.  That's not programming.

Share this post


Link to post
Share on other sites
skyhighweb    0
19 hours ago, justsomeguy said:

You're not printing any of those options into the select list.

This is the problem with not understanding the code you are working with.  We are here to help people learn how to program.  We expect people to start on their own, and make an effort.  If you're not going to go through the tutorials to learn the basics about how this stuff works, how can we help you?  Just doing everything for you does not teach you anything except that when you have a problem you come here to get the answer.  That's not programming.

yeah true, but fixed anyway.

Share this post


Link to post
Share on other sites
skyhighweb    0
On 5/20/2017 at 9:39 AM, dsonesuk said:

IS $willlose = mysql_real_escape_string($_POST['willlose']); returning a value?

Just make sure it returns a value first, and this

</select></div>

should be UNDER the php outputted options.

tried that didnt work

i got this other code been working on the menu part works fine but the submenu after converting to mysqli refuse to work

 

$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>');
		$.get('bid.php?menu=' + $(this).val(), 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>

 

Share this post


Link to post
Share on other sites
skyhighweb    0

	<?php 


$query = "SELECT a.id, a.team1, a.title, a.team2, s.team_id, s.teams, u.nick, b.id, b.willwin, b.willlose, b.bidder, b.auction FROM bids b 
LEFT JOIN " . $DBPrefix . "users u ON (u.id = b.bidder)
LEFT JOIN " . $DBPrefix . "auctions a ON (a.id = b.auction)
LEFT JOIN " . $DBPrefix . "sports s ON (s.team_id = b.willwin)
WHERE b.willlose = :menu and a.id = :auc_id and b.bidder NOT IN ('b.tagged') and b.tagged IN ('b.bidder')";
$params = array();
		$params[] = array(':auc_id', $id, 'int');
		$params[] = array(':menu', $menu, 'int');
		$db->query($query, $params);
		
while ($row = $db->fetch()) {
	echo "<option value=''></option>";
	echo "<option value='$row[team_id]'>$row[nick]...$row[teams]</option>";
}
?>

 

Share this post


Link to post
Share on other sites
dsonesuk    712

IF you are using MYSQLI then this is

mysql_real_escape_string($_POST['willlose'])

IS WRONG!

it should be

mysqli_real_escape_string($_POST['willlose'])

Notice 'i' at end of 'mysql', most if not all of these specific mysqli functions begin with 'mysqli'.

Share this post


Link to post
Share on other sites
skyhighweb    0
4 minutes ago, dsonesuk said:

IF you are using MYSQLI then this is


mysql_real_escape_string($_POST['willlose'])

IS WRONG!

it should be


mysqli_real_escape_string($_POST['willlose'])

Notice 'i' at end of 'mysql', most if not all of these specific mysqli functions begin with 'mysqli'.

tried all that, aam dropping the code.

Share this post


Link to post
Share on other sites
justsomeguy    954

tried that didnt work

This is the single worst response you can probably give.  If you did it right, then it would have worked.  If it didn't work, then you didn't do it right, but you didn't show any code to allow anyone to point out what you did wrong.  It's not like people suggest all of these PHP functions that just don't work, PHP works fine, you're just not using it right, and you're also not showing anyone else what you did so that we can point out your errors.  Incidentally, this is also why I stopped responding to your threads.  I'm not here to do peoples' work for them, I'm trying to teach people.

Share this post


Link to post
Share on other sites
skyhighweb    0
3 minutes ago, justsomeguy said:

 

 

This is the single worst response you can probably give.  If you did it right, then it would have worked.  If it didn't work, then you didn't do it right, but you didn't show any code to allow anyone to point out what you did wrong.  It's not like people suggest all of these PHP functions that just don't work, PHP works fine, you're just not using it right, and you're also not showing anyone else what you did so that we can point out your errors.  Incidentally, this is also why I stopped responding to your threads.  I'm not here to do peoples' work for them, I'm trying to teach people.

ok, like i said i drop the code, i was interfereing with the loading speed and wasnt work well i tried another one still working on that one.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×