0

Update 02:

As requested in the comments on my original question I am including my actual schema and will try and explain better based on what FunkFortyNiner said.

Any confusion or if you are unsure please comment and ask me questions! I am unable to go into PHP chat due to my rep and have gone over this question numerous times now!

DB_2

Field    Type    Null    Key    Default    Extra
id      int(11)    NO    PRI    NULL    auto_increment
key    varchar(25) NO           NULL
r_name varchar(50) NO           NULL
r_uid  int(255)    NO           NULL

DB_1

Field     Type       Null    Key    Default    Extra
id        int(11)     NO     PRI    NULL    auto_increment
u_name    varchar(50) NO            NULL
pass      varchar(255)NO            NULL
sub_start datetime    NO            CURRENT_TIMESTAMP
sub_end   datetime    NO            NULL
is_r      int(1)      NO            NULL
admin     int(1)      NO            NULL
a_key     varchar(25) NO            NULL

Okay so far everything that I have done is working fine and as I want it too.

I have asked this question for help with doing the part I am stuck on.

Say DB_2 is filled with some data.

I have a form on my site currently which when I fill it out it inserts the data into DB_1.

I want to add a dropdown to the form to display the keys from DB_2 (this part is easy and plenty of already existing questions on this)

What I am actually stuck on is then having it so once the key has been taken from DB_2 and inserted into DB_1 by my form I no longer want to be able to select that key from the dropdown (otherwise I run this risk of adding duplicates!

I hope this is easier to understand and less confusing/likely to be seen as a duplicate! Please feel free to ask my any questions or to further explain something before you just write this question off as unnecessary or already asked!

Thanks a lot for taking the time to read all of this! :)

---------------------------------------------------------------------------


Original Question (prior to being re-explained)

I have a quick question on a topic that I'm quite a noob about. I have a website I made that connects to a mysql database through php.

I have a form which I want to include a dropdown in and I want the data inside the dropdown to be taken from a column in my DB.

The thing is I also want it so that once that data is then saved in my DB it no longer shows up in the dropdown.

So example db schema

DB_1
------------------
Column_1 | Column_2 | Column_3
------------------

DB_2
--------------------
Column_1 | Column_2
--------------------

Example/Explanation of what I want to do:

So my form inserts data into DB_1 I want the dropdown to display all the results from DB_2/Column_1

Once DB_2/Column_1 matches DB_1/Column_3 for example then I no longer want that value to show up in the dropdown anymore.

Hope that makes sense and I explained it well enough!

Thanks :)

EDIT: Not a Duplicate Question! This was marked as duplicate and suggested the following: php mysql displaying results as drop down list Answer: "Assuming all you're trying to do is echo these rows into a dropdown:"

That is not all that I am trying to do. I also do not want the data to show up in the dropdown if it appears in DB_1

Hope this clarifies things! Thanks again :)

1 Answer 1

0

Since you want the option from DB_2 not to appear on the dropdown after its selected and saved, you can simply run another query that deletes the row from DB_2 immediately after its submitted to DB_1.

Or better still, have a Status column on DB_2 with a 0 or 1 value, default value being 1 and run an UPDATE query to change it to 0 after its been selected and saved. On your form dropdown you only query rows with Status as 1.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.