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
4 Réponses
+ 2
Your query looks correct.
+ 1
Did you get an error message running that query? if so, what did the message say?
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)."
)
";
0
Sameer Javed did you get any errors ??