I've problem in fetching data from MySQL | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

I've problem in fetching data from MySQL

Store db as comma separated string and i want to retrieve data from a string separated by commas. https://code.sololearn.com/wKW8F3caReUY/?ref=app

29th Jul 2021, 11:09 AM
Sameer Javed
Sameer Javed - avatar
4 Answers
+ 2
Your query looks correct.
29th Jul 2021, 12:41 PM
AKSHAY🇮🇳
AKSHAY🇮🇳 - avatar
+ 1
Did you get an error message running that query? if so, what did the message say?
29th Jul 2021, 12:26 PM
Ipang
0
//$userData['city'] = 27 //cities in db are saved as 12,33,9,2,1,27,31 //$userData['hobbies'] = 3,24 //hobbies in db have values as 3,24,17,31 // how to i match these records/arrays by my sql db records $SQL = "SELECT * FROM users_stats WHERE type = '1' AND ( ".in_array( $userData['city'] , explode(",", "'cities'") )." OR cities IN('all','pak') ) AND ( time = ".$currentTime." OR time = 'all' ) AND ( ".((array_intersect( explode(",",$userData['hobbies']) , explode(",", "'hobbies'")) != null)?1:0)." ) ";
30th Jul 2021, 1:57 AM
Sameer Javed
Sameer Javed - avatar
0
Sameer Javed did you get any errors ??
30th Jul 2021, 12:28 PM
AKSHAY🇮🇳
AKSHAY🇮🇳 - avatar