mysql - How do I select specific value using Php and preg_match using comma delimited? -
I am trying to select a certain numeric value that is different than a comma, the values are from a mysql db. I try to use the pillar blast, but I'm not sure how to catch a certain value. Any help would be appreciated.
Code Assume that you store a comma-separated list of values in columns You are if you blasted the result, then you An array is found form Now you want to know that 17 is an element of this array. right? You can do this with Maybe I completely misunderstood your problem. In this case, please explain with examples what your problem is actually what you have tried and where you got stuck. PS: I would not recommend storing separate lists in MySQL with commas and it would be a good idea to leave the use of mysql_ * functions because they 're excluded instead of mysqli or PDO Use the.
$ query = mysql_query ("Select from id_array WHERE id = '$ id'"); While ($ result = mysql_fetch_assoc ($ query)) {$ get_id = $ result ['id_array']; } $ Exact = explosion (",", $ get_id);
id_array , ie
12,17,44,13
$ is an array correct: ([0] => '12' [1] => '17' [2] => '44' [3] => '13')
$ check = in_array (17, $ exact); // True, if found as my example // Please note, finding in strict mode is not important. // 100 test, not in the list $ check = in_array ($ 100, $ exact) // Returned
Comments
Post a Comment