![]() |
|
Welcome to the Computer Webmaster Gaming Console Graphics Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
| |||||||
| Database Database problems or need to ask a question? maybe something to do with sql injections or a database software question. Database topics cover MySQL, PostgreSQL, Oracle, SQL Server or anything else related to databases. |
![]() |
| | LinkBack | Thread Tools | Display Modes |
| | #1 | ||
| Hi y´all, recently we´ve setup a webshop (mysql & php based) for a customer. All fine and neat... Now, after some thirdparty remodding, we learned that parts of the article detail pages no longer had the looks they once had. Especially the content of tables within the descriptive text (all in one field of the db) are now in need of a tiny little correction. The tag <table> should somehow be enhanced to <table class="data"> but with more than 1200 articles it´s no fun thing to consider doing it by hand So my question regards the handling of given content of one single db-field, call it 'product_description'. Is it possible to build a statement that uses 'product_description' in each and every article? Sure: SELECT 'product_description' FROM shopdb... But how would I go on telling MySQL that I wish it to check every single articles 'product_description', search for all occurrences of "<table>" within them and replace each one of them with "<table class="data">" in one step? Would this require some "assistance" say from php? If so how would you formulate that? Sorry for my blunt request for a working solution but I wouldn´t ask here if my own research had been successful. Perhaps I can´t see the woods for the trees, so any help or push in the right direction would really be appreciated... Best regs Alex | |||
|
| Advertisements |
| | #2 | ||
| "Alexander Schoenhoff" <aschoenhoff@web.de> wrote in message news:dcbm6e$dad$02$1@news.t-online.com... > Hi y´all, > > recently we´ve setup a webshop (mysql & php based) for a customer. All > fine > and neat... > > Now, after some thirdparty remodding, we learned that parts of the article > detail pages no longer had the looks they once had. > Especially the content of tables within the descriptive text (all in one > field of the db) are now in need of a tiny little correction. > > The tag <table> should somehow be enhanced to <table class="data"> but > with > more than 1200 articles it´s no fun thing to consider doing it by hand > > So my question regards the handling of given content of one single > db-field, > call it 'product_description'. > Is it possible to build a statement that uses 'product_description' in > each > and every article? > > Sure: > SELECT 'product_description' FROM shopdb... > > But how would I go on telling MySQL that I wish it to > check every single articles 'product_description', > search for all occurrences of "<table>" within them > and replace each one of them with "<table class="data">" in one step? > > Would this require some "assistance" say from php? If so how would you > formulate that? > > Sorry for my blunt request for a working solution but I wouldn´t ask here > if > my own research had been successful. > Perhaps I can´t see the woods for the trees, so any help or push in the > right direction would really be appreciated... > > Best regs > > Alex Why not set the default CSS for <table> to be what you want and set up specific classes for the other instances of <table> that need different formatting - you should be able to search and replace using a text editor. If you really have to do the tag modification on the fly take a look at the MySQL language reference manual (section 12) there are some quite comprehensive string manipulation functions there. This will slow down the site or at least cane the database server unnecessarily though. Ron | |||
|
| | #3 | ||
| Hi Ron and thanks for your helpful response, > Why not set the default CSS for <table> to be what you want and set up > specific classes for the other instances of <table> that need different > formatting - you should be able to search and replace using a text editor. That´s correct. However, as i wrote, the problem is, that there are way too many entries in our articles-db do make those changes manually. We could though change the tables within the "carrier-page" to be "CSS-classified". Thus a change in class-definition for the general table-tag (the ones in the descriptive text without a class-definition) would do the trick... So your advice in this case is quite logical and would help me correct the described situation. Thing is, it´s often the case that there are other, "normal" words or lines within a db´s field that need correction, f.e. just plain text parts in every articles description that have to be changed as per customers demand. So I´m afraid my example with the table-tag was poorly chosen - it´s the latter challenge - plain text - we´d need to master. > If you really have to do the tag modification on the fly take a look at the > MySQL language reference manual (section 12) there are some quite > comprehensive string manipulation functions there. This will slow down the > site or at least cane the database server unnecessarily though. Your implication is right again - the modifications are not meant to be on the fly, as that would definitly slow down the server. They are meant to be made by using one correctional statement like UPDATE (if that is the right candidate for this task) or one process to be initiated. My own findings so far: As one seems no to be capable of doing it by using MySQL alone, MySQL needs to be supported by a (php-,asp-,jsp-)scripted procedure to make the required changes. 1. select and open the db - no problem 2. choose the table(s) in the required db - no problem 3. SELECT the fields content (into an array?) - "wee bit" of a problem 4. use REGEXP to find the "suspects" - BIG problem 5. change them into the new form - still BIG problem 6. write the last changed field content back to the db - should be possible to solve As well as I´m capable of describing the process I´m a noob in writing the necessary code f.e. in PHP when it comes to the regexp-part. But if... say PHP is a must to make this work my request may be in the wrong newsgroup.... However I´m still writing this here just in case someone else has already mastered this and is willing to shed a light ... Thanks for your comments in advance... | |||
|
| Featured Websites | ||||
|
![]() |
| Tags: change, content, dbfields, part, possible, sql, statement |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| HOW TO : concat text fields using a GROUP BY statement ? | Fred | Database | 1 | 05-31-2007 7:41 PM |
| 2 where clause in same statement Mysql 4.2 | Xavier Houppertz | Database | 3 | 05-31-2007 7:40 PM |
| Quickform: how to check two fields in one function using registerRule() | l Burnerheimerton | Pear | 1 | 05-20-2007 5:34 PM |
| Featured Websites | ||||
|