/    Sign up×
Community /Pin to ProfileBookmark

Dropdown list – insert into Mysql

Hi all!
Hope this is the suitable section to post this question.
This is something probably simple but confuses me.
I simply want to add a dropdown list where, when an option is selected, its value will be inserted into a dbase table. More specifically, assume there is a php page where the user sees his order. He will be able to select the order status (pending or delivered). So, for example, if his ordered is delivered, by selecting “delivered” option, “delivered” will be inserted into the ‘Status’ Table.

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@LiLcRaZyFuZzYDec 16.2005 — the value from a dropdown list is selected like this:
[code=php]
# $status now contains either 'delivered' or 'pending'
$status = $_POST['select_status'];

# the query would look like
$query = "UPDATE Status SET fieldname = $status WHERE something=whatever";
[/code]


while the markup would be something like:
<i>
</i>&lt;select name="select_status"&gt;
&lt;option value="delivered"&gt;delivered&lt;/option&gt;
&lt;option value="pending"&gt;pending&lt;/option&gt;
&lt;/select&gt;
Copy linkTweet thisAlerts:
@renesisauthorDec 16.2005 — Thanks for the reply.

What is the purpose of "...WHERE something=whatever"? I mean, how can I use it?

Regards.
Copy linkTweet thisAlerts:
@LiLcRaZyFuZzYDec 16.2005 — e.g.:

if you have many entries in the table, with unique ids:
[code=php]
$query = "UPDATE Status SET status = $status WHERE id=$id";
[/code]
×

Success!

Help @renesis spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...