dharm Posted May 7, 2007 Share Posted May 7, 2007 Hi, im having some trouble with this bit of code. im sure its an easy fix but i cnt seem to put my finger on it. $catline = "222,223,224,225,"; WHERE cat IN ('".substr(str_replace(",","','", $catline),0,-3)."') Any suggestions will be much appreciated. thx! Quote Link to comment https://forums.phpfreaks.com/topic/50382-mysql-in-clause-with-php/ Share on other sites More sharing options...
boo_lolly Posted May 7, 2007 Share Posted May 7, 2007 use explode() Quote Link to comment https://forums.phpfreaks.com/topic/50382-mysql-in-clause-with-php/#findComment-247411 Share on other sites More sharing options...
Barand Posted May 7, 2007 Share Posted May 7, 2007 <?php $catline = "222,223,224,225,"; // lose last comma $catline = trim($catline,','); echo "WHERE cat IN ($catline)"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/50382-mysql-in-clause-with-php/#findComment-247499 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.