Jump to content

search and update or insert


csharpy

Recommended Posts

I use php and mysql to generate new webpages for my site... what i would like to do is pull information from my mysql database and wherever there is a certain pattern, i would like to insert HTML code before and after that pattern or possibly just replace the pattern. An example would be for creating a link to sayyyy google, wherever there is the term "google" in the text. Hopefully you understand what i'm asking.

 

an example would be...

before the search and insert...

"why don't you try using google for that?"

after the search and insert...

"why don't you try using <a href=http://www.google.com> google </a> for that?

Link to comment
Share on other sites

What haku meant was in PHP, you can do this -

str_replace('google', '<a href="http://www.google.com">google</a>');

 

In SQL, you can do this -

SELECT REPLACE(column, 'google', '<a href="http://www.google.com">google</a>') AS linky
FROM tablename;

Link to comment
Share on other sites

Great it worked!  I appreciate the help.  This is the first question i've posted and will be posting more now that i know i get fast support!!!  thanks again!

Posting something other than asking-for-help topics would be nice. Give something back to the community. Don't be selfish. :)

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.