lokesh_kumar_s Posted February 26, 2010 Share Posted February 26, 2010 let us assume $ssn={001,002,003} and i want to execute ike select username from city where ssn in (001,002,003) but i am having the vaues inside array $ssn i want to do like this select username from city where ssn in ($ssn) now tell me how do i convert $ssn to 001,002,003 please suggest if i could use list. Link to comment https://forums.phpfreaks.com/topic/193470-php-array-for-mysql-statement/ Share on other sites More sharing options...
aebstract Posted February 26, 2010 Share Posted February 26, 2010 $ssn is an array? When you do print_r($ssn) do you get something like Array (0=>001, 1=>002, 2=003) ? Link to comment https://forums.phpfreaks.com/topic/193470-php-array-for-mysql-statement/#findComment-1018526 Share on other sites More sharing options...
developerdave Posted February 26, 2010 Share Posted February 26, 2010 Why do you have squirly brackets? doesnt look to me like you need an array you could just build the string like this '001','002','003' And put it in your query like that If you do need to use an array you should really just use a normal PHP array, yours looks like a Json array so $ssn = array('001','002','003'); Link to comment https://forums.phpfreaks.com/topic/193470-php-array-for-mysql-statement/#findComment-1018534 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.