csharpy Posted June 10, 2009 Share Posted June 10, 2009 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? Quote Link to comment https://forums.phpfreaks.com/topic/161733-search-and-update-or-insert/ Share on other sites More sharing options...
haku Posted June 11, 2009 Share Posted June 11, 2009 strreplace('google', '<a href="http://www.google.com">google</a>'); Quote Link to comment https://forums.phpfreaks.com/topic/161733-search-and-update-or-insert/#findComment-853434 Share on other sites More sharing options...
Ken2k7 Posted June 11, 2009 Share Posted June 11, 2009 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; Quote Link to comment https://forums.phpfreaks.com/topic/161733-search-and-update-or-insert/#findComment-853536 Share on other sites More sharing options...
fenway Posted June 11, 2009 Share Posted June 11, 2009 This something that doesn't need to be done by the DB. Quote Link to comment https://forums.phpfreaks.com/topic/161733-search-and-update-or-insert/#findComment-853700 Share on other sites More sharing options...
csharpy Posted June 16, 2009 Author Share Posted June 16, 2009 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! Quote Link to comment https://forums.phpfreaks.com/topic/161733-search-and-update-or-insert/#findComment-856791 Share on other sites More sharing options...
Ken2k7 Posted June 16, 2009 Share Posted June 16, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/161733-search-and-update-or-insert/#findComment-856836 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.