update database with dropdown menu

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cyberguytr
    New Member
    • Feb 2010
    • 1

    update database with dropdown menu

    Hi,

    I have a small code is listing mysql records in php+html screen. ex:

    id, name, email, phone, status
    1 test test@test.com 12345 1 -----> dropdown
    2 test1 test1@test1.com 22222 3 -----> dropdown

    I just want to change one record with a dropdown box at the same screen. ex: status option "1,2,3..."

    for example let's say 1st record status is "1" and I want to change the value to "3" while I was querying all the records.

    I hope explanation is clear,

    Is there some sample script for my question

    Thanks
  • dlite922
    Recognized Expert Top Contributor
    • Dec 2007
    • 1586

    #2
    There's a few ways to do this. The best one depends on your setup.

    Here's one:

    1. Put the unique id of these records in line with the rest of the record, and the dropdown, in a hidden html form.

    2. Loop through your records and issue an update statement for each of records.

    Although this would mean, records who's status didn't change, would also get an update statement. This is not real big issue for a few records but if you have tens or hundreds it might be a good idea to update only the ones that did change status.

    For this, again you can use a hidden form field to store the previous status value. In your loop you would compare the current value with the previous value, if different, you then issue an update statement.

    Alternatively you could just have a boolean flag hidden field that changes from 0 to 1 when the record is changed.

    Why is the status 1? does it really have a business meeting or is it an application design carried over to the business.

    What I mean is , does the 1, 2, 3 represent a meaning or word in English? For example 1 = Not Called, 2 = Called and Interested, 3 = Called and Not Interested.

    If so, then you should display that for the user between the <option></option> tags and just put the numbers in the <option value=""> parameter.

    <option value="1">Custo mer Called</option>
    <option value="2">Custo mer Interested</option> etc...

    Good luck,






    Dan

    Comment

    Working...