Re: set array
| From: | John Taylor-Johnston | Date: | Tue, 26 Nov 2013 04:08:55 +0000 |
| Subject: | Re: set array | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-322504@lists.php.net to get a copy of this message | ||
I have a SET field in MYSQL.
'1. Type One','2. Type Two','3. Type Three' The user can multi-select <select name="DPRtype[]" multiple> <option value="1. Type One"> <option value="2. Type Two"> <option value="3. Type Three"> </select> I just dont know how to express $_POST[DPRtype] to be able to build the $SQL to express the separate possibilities. $sql = "UPDATE$MyString = express_value_select ($_POST['DPRtype'],"1. Type One"); $MyString .= express_value_select ($_POST['DPRtype'],"2. Type Two"); $MyString .= express_value_select ($_POST['DPRtype'],"3. Type Three"); function express_value_select($tofilter,$tofind) { foreach($tofilter as $value){taylorjo.CRTP_CGASETDPRtype= '$_POST[DPRtype]' "; If I use a foreach like this, it will be very clunky. And I'll have an extra comma at the end. What is a cleaner way?
if ($value == $tofind) echo $tofind.",";
}
}