Jump to content

php array for mysql statement


lokesh_kumar_s

Recommended Posts

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

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');

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.