common Posted August 4, 2009 Share Posted August 4, 2009 Hi everyone! I was wondering if anyone could help me?? I have a database and one of the column have values like 3, 7, 31, 4, 6 and so on. Is there a php mysqli function that can call these values in a array?? Because I have a variable that can contain a number between 1 and 31 and I want to check if it matches to a value in the column... thanx Link to comment https://forums.phpfreaks.com/topic/168773-php-mysql/ Share on other sites More sharing options...
phpSensei Posted August 4, 2009 Share Posted August 4, 2009 You want to do this in one query? Link to comment https://forums.phpfreaks.com/topic/168773-php-mysql/#findComment-890430 Share on other sites More sharing options...
common Posted August 4, 2009 Author Share Posted August 4, 2009 if there is a way yes...I just don't know of an easy way, just a long way... So i was wondering if there is not an easy way Link to comment https://forums.phpfreaks.com/topic/168773-php-mysql/#findComment-890437 Share on other sites More sharing options...
phpSensei Posted August 4, 2009 Share Posted August 4, 2009 You can use PHP <?php /*mysql query*/ $values = "3,7,31,4,6"; $array_values = explode(",",$values); // Now the values are in a array $num = 5 // this is the number you want it to match if(in_array($num,$array_values)){ print "We have a positive ID."; } ?> Link to comment https://forums.phpfreaks.com/topic/168773-php-mysql/#findComment-890441 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.