NerdConcepts Posted July 6, 2007 Share Posted July 6, 2007 I know how to run searches in MySQL but not on a PHP variable. I've got a variable when is a product description. I need to check to see if it has the word 'BULK' in the variable and then if it does I'll be running a MySQL insert query that actually makes that one product 10 different ones, not biggie on that, I know how to do it. Just the searching of the variable for the word "BULK" is my only problem. Sorry I know this is probably really simple but I can't find anything on the internet about it. Link to comment https://forums.phpfreaks.com/topic/58655-solved-search-variables-for-a-word/ Share on other sites More sharing options...
teng84 Posted July 6, 2007 Share Posted July 6, 2007 im lazy to type try this http://w3schools.com/php/php_mysql_select.asp Link to comment https://forums.phpfreaks.com/topic/58655-solved-search-variables-for-a-word/#findComment-290982 Share on other sites More sharing options...
NerdConcepts Posted July 6, 2007 Author Share Posted July 6, 2007 What does that have to do with searching a PHP variable? This is just putting MySQL data into variables. I already have the variable, after it is searched for the word "BULK" it runs either 1 of 2 queries; and those, like I said, I already know how to do. Just need to know how-to search a PHP variable for the word "BULK" or really any word that is, but mainly "BULK". Link to comment https://forums.phpfreaks.com/topic/58655-solved-search-variables-for-a-word/#findComment-290987 Share on other sites More sharing options...
tippy_102 Posted July 6, 2007 Share Posted July 6, 2007 I think you're looking for strpos http://ca.php.net/manual/en/function.strpos.php Link to comment https://forums.phpfreaks.com/topic/58655-solved-search-variables-for-a-word/#findComment-290989 Share on other sites More sharing options...
rcorlew Posted July 6, 2007 Share Posted July 6, 2007 $string = "my data to search";//could be your $data[row] from sql most likely if(stristr($string, 'BULK') === FALSE) { //do whatever query would be if BULK was not there } else if(stristr($string, 'BULK') !== FALSE) { //run the query if BULK is found } Link to comment https://forums.phpfreaks.com/topic/58655-solved-search-variables-for-a-word/#findComment-290990 Share on other sites More sharing options...
NerdConcepts Posted July 6, 2007 Author Share Posted July 6, 2007 Thanks a bunch trippy_102 and rcorlew Got a question, why is there 3 equal signs? When usually PHP using '==' for equal to and '!=' for not equal to? Is this something weird or does it actually have functionality? Link to comment https://forums.phpfreaks.com/topic/58655-solved-search-variables-for-a-word/#findComment-291001 Share on other sites More sharing options...
rcorlew Posted July 6, 2007 Share Posted July 6, 2007 in php the number 0 can be an actual result, and the number 0 can mean NULL(meaning false) if you use === it will actually look to see if the result is FALSE or "0" Link to comment https://forums.phpfreaks.com/topic/58655-solved-search-variables-for-a-word/#findComment-291003 Share on other sites More sharing options...
NerdConcepts Posted July 6, 2007 Author Share Posted July 6, 2007 I get it, thanks a bunch again. Link to comment https://forums.phpfreaks.com/topic/58655-solved-search-variables-for-a-word/#findComment-291383 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.