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?
Julian HansenConnect With a Mentor Commented:
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

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.

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.