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

Link to comment
Share on other sites

$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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.