Add Drop Down to PHP Form

I would like to add a drop down selection on my php form.

Name -= Onetime

(lookup data is in two tables)

table1 = teams
column =

table2 = picksummary
columns =

The teams table has a list of teams.
I would like to lookup the teams in the teams table and then reference the picksummary table to check it the team exists in picksummary.onetime column based on the current week and userid

If the team does exist in that column then do not display the team in the dropdown.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Julian HansenCommented:
so something like this
(assumes $userid holds the userid and $weeknum holds weeknum )
// Connect to DB
$link = mysqli_connect("localhost", "user", "password", "database");

// Check for connection error
if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());

// Retrieve userid and weeknum
$userid = "Set user id here";
$weeknum = "Set weeknum here";

// Build query
$query = "SELECT * FROM teams 
    WHERE teamid NOT IN (
      SELECT onetime FROM picksummary WHERE userid = '$userid' AND weeknum = '$weeknum')";

// Execute query
$result = mysqli_query($query);

// Start dropdown
echo '<select name="onetime">';

// Start results loop
while($row = $result->fetch_object($result)) {
    echo '<option value="' . $row->teamid . '">' . $row->teamid-> . '</option>';

// Free the result

// End the drop down
echo '</select>';

// Close the connection

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ray PaseurCommented:
If you will post the CREATE TABLE statements and a little bit of the test data (this is called the SSCCE) we may be able to give you a tested and working example.

The example here appears to have a syntax error on line 21, missing the first argument which is the data base connection link.  The relevant man page is:
MPDenverAuthor Commented:
Here is the file I will be adding this option to.  I was attempting to have this work similar to tiebreakerpoints.  I was going to add this below line 186

"                        echo '<p><input type="text" name="tieBreakerPoints" id="tieBreakerPoints" size="3" value="'.$tieBreakerPoints.'" readonly="true"> <label for="tieBreakerPoints">Total points in the Monday night game (tiebreaker) - Locked</label></p>';      

Attached below are the three pieces I am trying to add this to.

Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

MPDenverAuthor Commented:

Ray did I need to include anything else?
Julian HansenCommented:
Your table definitions

The code posted earlier is a skeleton of what is required - you need to modify the bits to make it work with your code.
Ray PaseurCommented:
You should close this question and hire a professional developer to help with this programming.  You've got 551 lines of code in three files and when the problem cannot be reduced below hundreds of lines of code, it's no longer a question that has any answer.  It's a requirement for application analysis and development that will take considerable time and specialized knowledge about your data.  

That's why I asked for the SSCCE, including the table definitions and a little bit of test data.  If the question cannot be reduced to something that can be answered in the EE forum, maybe a paid professional would be the right approach to success.

In any case, good luck with it, ~Ray
MPDenverAuthor Commented:
Well my original questions was just that.  All I asked for was guidance on adding a drop down.  I am trying to learn php and was going to attempt to do the rest.  I was hoping for assistance on that but ill close it.

I added the additional files to show what I was attempting.  I didn't expect you to do the work or I would of asked that in the first place.
Julian HansenCommented:
Do you have a link for us to see to put this in context?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.