Jump to content

[SOLVED] Search variables for a word?


NerdConcepts

Recommended Posts

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

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".

$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

  }

 

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.