473,404 Members | 2,137 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

How to update a user selected drop down menu value to database

Hi,

I am new to this site . I am looking for some help in updating my database from the value selected by user.

Heres my page I have a table with rows of ID and its status. Status is a drop down menu with 4 possible options. The default displayed is the value from database. When the user picks a value form drop down menu say "completed" I want this value to be updated fro that particular id to database.
Heres my script to create drop down:
Expand|Select|Wrap|Line Numbers
  1. <td WIDTH=200 HEIGHT =40 align="center" rowspan="2">STATUS<form id="main_form" name="main_form" method="post" action="userZFN.php"></td>
  2. <option value="HOLD" <?php if($row['STATUS']=="HOLD") { echo "selected"; }?>>HOLD</option>
  3. <option value="ASSIGNED" <?php if($row['STATUS']=="ASSIGNED") { echo "selected"; }?>>ASSIGNED</option>
  4. <option value="PROGRESS" <?php if($row['STATUS']=="PROGRESS") { echo "selected"; }?>>PROGRESS</option>
  5. <option value="COMPLETE" <?php if($row['STATUS']=="COMPLETE") { echo "selected"; }?>>COMPLETE</option>
  6. </select>
  7. <input type="submit" id="main_submit" name="main_submit" value="submit" />
  8. </form>
  9.  
This drop down is for each row of the status column.

When The user clicks submit by choosing some status value . I receive it in the same page using post.

Expand|Select|Wrap|Line Numbers
  1. }elseif( isset($_POST['main_select'])){    
  2. $lcSelectedValue = $_POST['main_select'] ;
  3. echo $lcSelectedValue;
  4.  
But when I use update I need to use something like this
"Update TABLE set COLUMN = 'progress' where ID = $id";


But How DO I remember the ID???Can I pass the ID through Post/select too???


Thanks for the help
Sep 22 '10 #1
4 10601
dlite922
1,584 Expert 1GB
Heya coder86! Welcome to Bytes!

Of course you can!! You can store it on the page in a hidden input field.

Try that and let us know,


Dan
Sep 22 '10 #2
Thanks for replying Dan,

It would be great if u can give me an example..
Sep 23 '10 #3
Thanks Dan,
I got it to work

Expand|Select|Wrap|Line Numbers
  1.     <?php echo "<input type=\"hidden\" id=\"hiddenzid\" name=\"hiddenzid\" value=\"$zid\"/>"; ?>
  2.  
Sep 24 '10 #4
dlite922
1,584 Expert 1GB
Cool! You're Welcome and thanks for posting the code to help others.

Dan
Sep 24 '10 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Greg Scharlemann | last post by:
I am attempting to populate a drop down menu based on the selection of a different drop down menu. However, it is not working correctly, I cannot figure out for the life of me what exactly happens...
1
by: Greg Scharlemann | last post by:
I would like to automatically populate a drop down menu when the page loads based on the selection of an item in a different drop down menu. I made a test page that when drop down #1 changes, drop...
8
by: barbarowa | last post by:
I've coded a script to populate a drop down menu from a database but I can't seem to get the PHP script to pass the selected item. The database only has two fields, ID and ITEM. I want the user...
4
by: Laura K | last post by:
I have a drop down menu which has a list of subcategories and the initial value is "please choose a Subcategory". When the user chooses a subcategory they are taken to a new page where the drop...
1
by: phpnewb | last post by:
Hi, I know i'm doing it wrong, but I'm using a while loop right now to create several instances of a drop down menu. It gives me undesirable results. Can you tell me the right way to do it. Below are...
2
by: Parz | last post by:
Hi am facing problem in retrieving the value selected from drop down menu in one page from the next page..Am using the following code to populate the drop down menu with values form the database. ...
2
by: millertime90 | last post by:
Hi basically my problem is I have 2 drop down menus populated by my database the first populated by a field in the database and the 2nd populated with a relation to the value selected in the first...
3
by: SQLjunky | last post by:
Hello, Contrary to what my screen name indicates, i'm actually quite new to SQL. Having said that, I'll get right into my problem. I'm trying to query an mssql database to return to the value...
2
by: giandeo | last post by:
Hello all, It's almost a couple of weeks since i am struggling to get this code work. Unfortunately, i am stuck. There seems to be no hope... Please Help....... I am working with an asp page...
6
by: phpnewbie26 | last post by:
My current form has one multiple select drop down menu as well as few other drop down menus that are single select. Originally I had it so that the multiple select menu was first, but this created...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.