Re: data from db
| From: | Jamie Alessio | Date: | Tue, 13 Feb 2001 01:01:46 +0000 |
| Subject: | Re: data from db | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-6559@lists.php.net to get a copy of this message | ||
> For instance, if I had a response to a question, called
> $row['description'], and I > searched for "%bryan%", the word
> 'bryan' would be a different color within the field $row['description']?
>
One way to do this:
Instead of directly outputting data to the browser using something like echo or
print you can store all of your output in a variable. You can then use
str_replace or ereg_replace to change the text to the color you want. For
example...
$search_word = "bryan";
$your_output = "The person searched for the word " . $search_word . ", so I want
to make it a different color";
$your_colored_output = str_replace($search_word, "<font color="red">" .
$search_word . "</font>", $your_output);
echo $your_colored_output;
Something like that should do the trick (I haven't tested that code though).
- Jamie