Much needed advice.

Discussion in 'JavaScript' started by CPAPubMichael, Nov 25, 2010.

  1. #1
    Hello,

    I have a drop down, maintaining values. Such as "Countries". I know there is a way of getting the select box to maintain a value from a database.

    e.g: on a edit account page, i would like it to show there current country, what will be selected from a database using PHP.

    I would be very grateful if someone could help, as i am not the best with JavaScript.

    Thank you in advance.
     
    CPAPubMichael, Nov 25, 2010 IP
  2. MattCA

    MattCA Peon

    Messages:
    14
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    It has nothing to do with JS I guess. You just do a db query, fetch data and in echo it in a PHP loop.
    Example:
     
    MattCA, Nov 25, 2010 IP
  3. CPAPubMichael

    CPAPubMichael Peon

    Messages:
    231
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thank you, i don't think i said it correctly.

    What i mean is; say when a user submits a register form, they select a country, but there is an error with the form. How would i get it to hold the value if it is NOT submitted into the database.

    Thanks once again.
     
    CPAPubMichael, Nov 25, 2010 IP
  4. MattCA

    MattCA Peon

    Messages:
    14
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    If you want to store data before the form gets submitted and processed by PHP, you need AJAX to send it to PHP and store in the database.
    If you don't do JS validation, so the form error you mentioned is generated by PHP, then before printing it do SQL insert.
     
    MattCA, Nov 25, 2010 IP
  5. CPAPubMichael

    CPAPubMichael Peon

    Messages:
    231
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thank you, you helped me a lot.
     
    CPAPubMichael, Nov 25, 2010 IP