Retrive multiple values from single dimension value / key JSON
Posted
by
jonnypixel
on Stack Overflow
See other posts from Stack Overflow
or by jonnypixel
Published on 2014-05-27T03:18:43Z
Indexed on
2014/05/27
3:27 UTC
Read the original article
Hit count: 181
I'm busting my head trying to work this out.
"ContentBlock1":["2","22"]
I have been trying to get the 2 and the 22 into a comma sepertaed string so i can use it within a MySQL IN(2,22)
query.
I currently have tried several ways but none seem to work for me.
$ContentBlock = my json data;
$cid = json_decode($ContentBlock,true);
foreach ($cid as $key){
$jsoncid = "$key ,";
}
And then:
SELECT * FROM content
WHERE featured=1 AND state=1 AND catid IN($jsoncid)
ORDER BY ordering ASC LIMIT 4");
© Stack Overflow or respective owner