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

  $ 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);  

Assume that you store a comma-separated list of values ​​in columns You are id_array , ie

  12,17,44,13   

if you blasted the result, then you An array is found form $ is an array correct: ([0] => '12' [1] => '17' [2] => '44' [3] => '13')

Now you want to know that 17 is an element of this array. right? You can do this with

  $ 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   

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.

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -