Knowledgebase

PHP/MySQL select query from array

Posted by netfreak, 09-22-2007, 09:06 PM
I've got an array containing around 10 unique numbers, and I'm trying to run a SELECT query which pulls the matching records from the DB using those unique numbers. When using "WHERE userid IN $arrayvar" it spits out an error as the array contains more data/characters than just the ID numbers (ie. "Array" "=>" etc). Any ideas for this?

Posted by netfreak, 09-23-2007, 12:01 AM
Nevermind, I think I've got everything working by running implode(",", $arrayvar) and using the result in the query.

Posted by deuce868, 09-23-2007, 12:33 AM
Yea, implode is your friend in those cases. Don't fotget to escape the values for db security.



Was this answer helpful?

Add to Favourites Add to Favourites

Print this Article Print this Article

Also Read
funio.com (Views: 610)


Language:

Client Login

Email

Password

Remember Me

Search