June 26th, 2000, 01:00 AM
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">
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
June 26th, 2000, 02:25 AM
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.
$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
// 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.
//No matching for drop down item...
echo "<option value="$drop_down_values[$a]">$drop_down_values[$a]</option>n";
//close the drop down.
You can optimize this script.
let me know the result.
"The fear of the LORD is the beginning of knowledge..."
June 27th, 2000, 12:34 AM
Thanks Shiju. The Code is working fine.