Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7991961
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T13:26:26+00:00 2026-06-04T13:26:26+00:00

I am pulling profiles which mention the word fitness from a database like so:

  • 0
  1. I am pulling profiles which mention the word “fitness” from a database like so:

    $result = mysql_query("SELECT profile FROM ".$table." WHERE profile LIKE ('fitness')");
    
  2. I am doing a basic retrieval of the $profile variable and echo it.

    while($slice = mysql_fetch_assoc($result)) {
        $profile = $slice['profile'];
        echo $profile;
    }
    

What I’d like is a way to search the text inside $profile for the word “fitness” and highlight the found word using maybe CSS.

Any ideas how?

UPDATE:

Ty very much, and I have one more problem.

In the sql query I will have:

$result = mysql_query("SELECT profile FROM ".$table." WHERE $profile_rule");

$profile_rule = 'profile LIKE ('fitness') AND profile LIKE ('pets')';

Is there a way to s**trip the $profile_rule** and get just the words fitness and pets? Maybe strip everything which isn’t encased by ” ?

Ty

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T13:26:29+00:00Added an answer on June 4, 2026 at 1:26 pm
    function highlightWord($word, $text){
        return str_replace($word, '<span class="highlighted">' . $word . '</span>', $text);
    }
    
    $profile = highlightWord('fitness', $profile);
    

    EDIT: Per your update, take a look at the IN() operator:

    $result = mysql_query("SELECT profile FROM $table WHERE profile IN ('fitness','pets')");
    

    EDIT 2: I think I misunderstood your question, though I still recommend edit 1. If you just want to grab the words fitness and pets from that $profile_rule string, use some simple regex:

    preg_match_all("|[a-z]+(?=\'\)|","profile LIKE ('fitness') AND profile LIKE ('pets')", $profiles);
    var_dump($profiles); // array(1) { [0]=> array(2) { [0]=> string(7) "fitness" [1]=> string(4) "pets" } }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im pulling a date from a database which is formatted like dd-mm-YYYY. What I
I'm pulling rows from a table in the database: title and COUNT(id) AS 'count'.
I am pulling data from one table, called analyzedCopy, and using it to over-rite
I am pulling values from a database that contain military time as 1330 (don't
I'm pulling in the XML from Twitter via OAuth. I'm doing a request to
I'm pulling in data from an external place database that returns JSON of information
I am pulling my data from a database and I am using json. What
I have the following query: select * from winners join profiles on winners.subscriber_id =
Im pulling data from a MySql data table. I'm pulling from a row called
I am pulling tweets from my twitter profile to my website. I'm adding REPLY,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.