Web Analytics Made Easy -
StatCounter php and select boxes - CodingForum


No announcement yet.

php and select boxes

  • Filter
  • Time
  • Show
Clear All
new posts

  • php and select boxes

    Hi, I have a database which has a table called 'skills' and another called 'user_skills'. I am displaying in a select box all skills from 'skills' and of those, the ones that a particular user has (from 'user_skills') are highlighted. This works fine, but I am trying to allow the user to change the skills they have and update the database. All I can seem to do at the moment is store all the originally selected skills in an array, so if they change their skills, it still only stores those they had before. I need to know how to store the NEWLY selected skills, so that they can be submitted with teh form for processing. Could somebody give me some idea how?

    I suppose what i am trying to say is how would I test to see if a particular element is selected, after they have been displayed?

    Cheers in advance.
    Last edited by heaps21; Feb 15, 2004, 01:59 PM.

  • #2
    $bleh = mysql_query....where user_id = '$id'");
    <form action="bleh.php" method="POST">
    <input type="text" name="bleh" value="<? echo $row['foo']; ?>">
    <input type="Submit" value="Submit" name="Submit">

    this will take (with some modifications) the values stored in the table where the users id is equal to a session you have created, and display the settings in textboxes, now all youve gotta do is make bleh.php with a UPDATE statement in it, and it updates it, heres the code for an update statement:
    mysql_query("UPDATE user_skills SET tablecolumn = '$yourvariable'");

    hope this helps.
    php & asp tutorials - the birthplace - biorust - photoshop and web technologies


    • #3

      Just to clarify:
      This array you're storing, it's storing the user's existing selection from when you loaded this page up?

      And you're able to load up the select box correctly, highlighting the existing selections? So I'm assuming this is a multiselect box?

      I suppose what i am trying to say is how would I test to see if a particular element is selected, after they have been displayed?
      So when you refer to an element, do you mean an option from the select box? If that is the case, and I'm not sure what you're look for exactly, then you'd be using Javascript's onChange even probably. That will tell you exactly when the user chooses a selection.

      You would refer to each selected item through selectBox.selected[i].value

      Here is a good set of Javascript functions for select boxes:

      Hope that helps,


      • #4

        Thanks, that helped a lot