July 1st, 2000, 06:03 AM
Join Date: Feb 2000
Time spent in forums: 3 h 26 m 22 sec
Reputation Power: 14
and check all three selections, only the last selection gets added to the database.
your variable is not an array so it can't hold the multiple values..
Insted of giving this in check box use a multiple select drop down menu.
<select size="5" name="rec" multiple>
<option selected value="Water Sports
<option selected value="Winter Sports">Winter Sports</option>
Once you save your record in a databse your data will saving with comma seperator like Wildlife,Winter Sports...
i guess saving of the records won't be problem for you.Following is an example showing how you can dispaly back the values to the drop down menu from database.
$drop_down_values=array(Water Sports,Wildlife,Winter Sports);
//First create an array with all the items of drop down menu.
// connectivity string.
$result=mysql_query("select field 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="rec" 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 implement the same logic with check box also..
[This message has been edited by Shiju Rajan (edited July 01, 2000).]