1. No Profile Picture
    Devshed Newbie (0 - 499 posts)
    Hi All

    I'm new to PHP/MySQL. I'm using two pages in my project. One for Inserting the profile of
    the users and other for updating the profile.

    I've a SELECT OPTION MULTIPLE tag in my insert.php3.

    <select name="busstype" multiple size="4">
    <option value="Importer">Importer</option>
    <option value="Exporter">Exporter</option>
    <option value="Manufacturer">Manufacturer</option>
    <option value="Supplier">Supplier</option>

    The User can select as per his wish. I'm inserting all the selected values into the
    database in a single field, the values are seperated by a delimiter comma(","). For eg.

    Suppose the user selects Importer, Exporter and Supplier, it will be stored as
    Importer,Exporter,Supplier for the particular user.

    Upto this it works fine for me.

    Going to Update page (update.php3), i'm able to display all the TEXT field values. also i
    want to display the SELECT OPTION MULTIPLE tag. I can split the values using split()
    function ( split(",",myrow["busstype"]) ).

    now i want to display the page to the user for updation with Importer, Exporter and
    Supplier SELECTED and the Manufacturer not selected.

    can anyone recommend me how to do this.

    Thanks in Advance
  2. #2
  3. .Net Developer
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Rep Power

    Here is the script which you are looking for.

    just modify this script as per you requirment.

    //First create an array with all the items of drop down menu.

    // connectivity string.

    //select database
    $result=mysql_query("select category from tblname where some conditions ",$con);
    // pass a query to mysql.

    //get the row values.

    $pieces = explode (",", $row["category"]);
    //separate the Item values.

    //take the total count of dropdown items.

    //count of selected items, which we fetched from database.

    echo "<select size="5" name=" category " multiple>n";

    //loop for populating selected values to the drop down.

    //don't match the value more than once..

    //loop for matching the selected item
    if ("$drop_down_values[$a]"=="$pieces[$b]"){
    // selected item matching with drop down item
    //make it as selected.
    echo "<option selected value="$drop_down_values[$a]">$drop_down_values[$a]</option>n";
    //this value is matching, and already made it as selected.
    //so donít match this value again.

    if ($repeat=="0"){
    //No matching for drop down item...
    echo "<option value="$drop_down_values[$a]">$drop_down_values[$a]</option>n";

    echo "</select>n";
    //close the drop down.


    You can optimize this script.
    let me know the result.

    Good Luck!!

    SR -

    "The fear of the LORD is the beginning of knowledge..."
  4. #3
  5. No Profile Picture
    Devshed Newbie (0 - 499 posts)
    Thanks Shiju. The Code is working fine.

Similar Threads

  1. Updating text fields from dynamic SQL select box?
    By Trent Hatred in forum HTML Programming
    Replies: 3
    Last Post: February 6th, 2004, 10:34 AM
  2. New Select box option (C#)
    By WisconsinGuy in forum .Net Development
    Replies: 1
    Last Post: February 5th, 2004, 09:40 AM
  3. Naming a SELECT box with setAttribute() issue
    By vbrtrmn in forum HTML Programming
    Replies: 1
    Last Post: January 15th, 2004, 01:21 PM
  4. displaying mysql result in a select box
    By notaloser in forum PHP Development
    Replies: 4
    Last Post: January 13th, 2004, 05:30 PM
  5. Access: list box/combo box "After Update" problems
    By hlove in forum Database Management
    Replies: 2
    Last Post: January 2nd, 2004, 01:22 AM

IMN logo majestic logo threadwatch logo seochat tools logo