hank9481 Posted April 27, 2008 Share Posted April 27, 2008 Hey guys, I'm very much a novice when it comes to PHP, but I'm learning it and trying to implement it on my site. I've run into an issue that I hoping someone can help me to fix rather quickly. I have a submission form which I am attempting to use. At the top of the page, you will notice the dropdown which I have managed to successfully populate with data from my SQL table. However, I have two problems. First, I would like for the dropdown population to only represent the players in the team dropdown lower on the page. For example, if I select Boston from the teams dropdown, I only want players on Boston to appear in the top dropdown. I also am planning to move the top dropdown below the others but have yet to do so. Second, I have the form setup to email the results to my server email using the recipient command; however, it is only submitting part of the information. Here is a copy of the line of code: print "<select name=winter id=player class=list style='width:500px'>"; $result = mysql_query("SELECT P.last_name, P.first_name, P.position, T.name FROM players P, teams T WHERE P.experience=0 AND T.team_id=P.organization_id ORDER BY organization_id ASC, last_name ASC") or die(mysql_error());; while ($row = @mysql_fetch_array($result,MYSQL_ASSOC)) { print "<option value=".$row{'last_name'}.", ".$row{'first_name'}.", ".$row{'position'}."-- ".$row{'name'}.">".$row{'last_name'}.", ".$row{'first_name'}.", ".$row{'position'}."-- ".$row{'name'}."</option>"; } print "</select>"; For whatever reason, the only thing getting to me via email is the last_name. I assume it is some form of syntax error, but I cannot figure out why I can't receive the rest of the information such as first_name, position, and team. Any help would be appreciated! Quote Link to comment Share on other sites More sharing options...
retro Posted April 27, 2008 Share Posted April 27, 2008 For the first part, you would need a JavaScript code to achieve this. Try looking at the following: http://www.weberdev.com/get_example-4578.html If that doesn't help, try the JavaScript forums on this very board! If you don't want to use JavaScript, I've done something similar in the past where the first option box is on one page. Once that is submitted, it takes you to a second page. The second page would do something like this: $teamLimit=$_POST["teamSelected"]; //use this query in the code for your option box $result=mysql_query("SELECT whatever,values,you,want FROM tablename ORDER BY whatever WHERE teamID = (' . $teamLimit . ')"); As for the second part, I'm not too great with that sort of syntax myself, as I am still learning. I wonder if this may help: When I had an option box for which i needed $row[FirstName] and $row[LastName], I found that it was ignoring the second item when I used commas. The solution was: echo"<option value='$row[iD]'>$row[FirstName] $row[LastName]</option>"; ...so a space seperating the strings, no commas. Quote Link to comment Share on other sites More sharing options...
DarkWater Posted April 27, 2008 Share Posted April 27, 2008 Use Ajax to do the thing that you want with the specific teams appearing in a select box. Quote Link to comment Share on other sites More sharing options...
hank9481 Posted April 27, 2008 Author Share Posted April 27, 2008 Use Ajax to do the thing that you want with the specific teams appearing in a select box. What exactly is Ajax? Quote Link to comment Share on other sites More sharing options...
retro Posted April 27, 2008 Share Posted April 27, 2008 It is a cleaning product Hehe, sorry... couldn't resist! Asynchronous JavaScript And XML. Quote Link to comment Share on other sites More sharing options...
dptr1988 Posted April 27, 2008 Share Posted April 27, 2008 First result in google: http://en.wikipedia.org/wiki/AJAX retro: Nice, i've always wanted to do that too! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.