2012-01-09 7 views
-2

この質問の目的のために何が置き換えられるかを書き留めました。これらのセクションは、全体として、MySQLデータベース内のエントリの1000を越えた順序で下に表示されます。私は複数の置換(どのように)を処理するか、PHP関数かmysqlのコマンドラインから実行するかどうかを理解する必要があります。MySQLのフィールドでHTMLとテキストの複数の部分を検索して置換する

(コードの場所で変化し得る)空虚と次のように置き換えます

<div style="margin-top: 3em;"> 
<h3>The Incandescent Light Bulb Lives!</h3> 
<strong><strong><strong> </strong></strong></strong> 
<div style="float: left; background-color: #c5c5c5; width: 320px; margin: 0px 8px 22px 0px; padding: 8px; text-align: center;"> 

<img src="images/image.jpg" alt="alt_text" width="292" height="250" /> 

<strong>Listen Now or Download for Later</strong> 

異なるオーディオタグ構造と

{audio}Why Congress Cannot Impose A Uniform Rule Of Tyranny ||http://mikesmith.com/mikes_audio/Dec_2011/20111219_church__sponsored.mp3{/audio} 
を次のように置き換え空虚と次のように置き換えます

<a class="jcepopup" dir="ltr" href="images/stories/Allison/help_with_audio_player.jpg" target="_blank">Help with Audio Player</a> 

このセクション内のHTMLは削除してください:

</div> 
<div style="margin-top: 3em;"> 

2011 Mike Smith 

Hey folks, its Mike Mike Smith with today's update. 

</div> 
<div style="margin-top: 3em;"> 

The incandescent lightbulb is back, it is legal and the ban, set to begin on January 1, 2012 has been repealed. That is the news across the wires today but it is only partially true. The Republicans in the house stuffed a provision in the $1 Trillion omnibus spending bill that prevents the Department of Energy from spending any money to enforce the ban which is still on the books. This begs the question for conservatives to answer: if Congress can forbid and or defund unconstitutional activities that regulatory agencies are making (like enforcing light bulb bans) then why cant the same Congress just un-fund enforcement of say The Endangered Species Act or the equally nefarious activities of the NLRB?Why couldnt Congress not fund ObamaCare? Why couldnt Congress un fund GM or AIG or bailouts to Fannie Mae and Freddie Mac? The answer is of course, Congress CAN ban those expenditures or just not fund them but this would take political courage and outside of standing shoulder to shoulder with Tom Edison what courage have we seen from them? The same can be said of almost any agency or activity that federal regulators are engaging in and people are demanding relief from. This seems like a perfect way to teach some constitutionalism to new members AND to secure Congressional conservatives budget cutter bonafides too but alas, the light bulb act seems to be a loss leader for censuring big government by starving it of funds. 

The next time you hear rigorous debate about how best to minimize the impact that the Feds have in say our public schools remember that their activity is funded by the Congress that proved it does not have to spend a dime on anything it does not want to including other bright ideas like studying monkeys high on the DEAs cocaine. Now who is the dim bulb that appropriated funds for that!? 

</div> 

異なるビデオ埋め込み構造でこのセクションを置き換えます

<div style="clear: both; margin-top: 8px; margin-bottom: 8px;"><object width="720" height="420" classid="clsid:02bf25d5-8c17-4b23-bc80-d3488abddc6b" codebase="http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0"><param name="src" value="http://mikesmith.com/mikesmith_movies/smithdoc/smith_hd_121911.mov" /><param name="autoplay" value="false" /><param name="cache" value="true" /><embed width="720" height="420" type="video/quicktime" src="http://mikesmith.com/mikesmith_movies/smithdoc/smith_doc_hd_121911.mov" autoplay="false" cache="true" /></object></div> 

は空虚で、次を置き換えます

<div style="float: right; margin-left: 8px; margin-bottom: 8px; clear: both;"></div> 
<div style="clear: both;"> 
<table style="background-color: #cccccc; border-collapse: collapse; border-color: #000000; border-style: solid;" summary="summary" border="3" cellspacing="0" cellpadding="8"> 
<tbody> 
<tr valign="top"> 
<td style="width: 100%;" valign="middle">Become a <a title="Become a 24/7 Backstage Pass member today and access exclusive members-only audio, video, and more." href="index.php/join-24-7/view-available-memberships" target="_blank">Become a 24/7 Backstage Pass member today.</a> to hear all of Mike's past interviews with Professor Gutzman, Ron Paul and more as well as exclusive access to the Post Show Show, Church Doctrine, and subscriber-only downloads.</td> 
</tr> 
</tbody> 
</table> 
</div> 
</div> 
{sidebar id=51} 
+0

ちょうど、すべてのレコードを読み込むPHPスクリプトを書くすべての置換を行うと、バックレコードを書き込みます。 **特に**の質問がありますか?これはQ/Aよりもむしろフリーランスの求人サイトに適しているようです。 –

+0

私の特に質問は、複数の置換を処理するPHP関数(またはmysqlコマンド)を作成する方法です。なぜあなたは職場を提案していますか?私はこれがどのように行われるのかを理解するために探しています。私は自分自身で表現を書くことができることに言及する必要があります。 –

+0

さて、私の答えはあなたにとって十分ではありませんか? –

答えて

0

は、それが

は(完全なコードのために、いくつかのフリーランスの仕事の現場に問い合わせる方が良いでしょう)PHPスクリプトは次の擬似コードを実装して書き込みを行うことができる方法ですすべてのレコードを反復クエリSELECT fields to replace FROM table
、代替品、次々ん:

while($row=mysql_fetch_assoc($res)) { 
    $data = $row['field']; 
    $data = preg_replace('pattern','replace', $data); 
    $data = preg_replace('pattern','replace', $data); 
    $data = preg_replace('pattern','replace', $data); 
    // and so on, whaever replacements you need. 

    // same goes for the other fields, if any: 
    $data1 = $row['field1']; 
    $data1 = preg_replace('pattern','replace', $data1); 
    $data1 = preg_replace('pattern','replace', $data1); 

    //and finally, by having all your replacements done, run an UPDATE query 

    $data = mysql_real_escape_string($data); 
    $data1 = mysql_real_escape_string($data1); 
    $sql = "UPDATE table SET field='$data', field1='$data1' WHERE id=".$row['id']; 
    mysql_query($sql) or trigger_error(mysql_error()." ".$sql); 
} 
-1

は、それが最短なのでさんは、一例として、二番目のを見てみましょう。次に、私はそれと一緒に短い別の例を示します。

UPDATE `table` SET `column` = REPLACE(`column`,'{audio}Why Congress Cannot Impose A Uniform Rule Of Tyranny ||http://mikesmith.com/mikes_audio/Dec_2011/20111219_church__sponsored.mp3{/audio}','') 
WHERE `column` LIKE '%{audio}Why Congress Cannot Impose A Uniform Rule Of Tyranny ||http://mikesmith.com/mikes_audio/Dec_2011/20111219_church__sponsored.mp3{/audio}%'; 
UPDATE `table` SET `column` = REPLACE(`column`,'BAD TEXT','') 
WHERE `column` LIKE '%BAD TEXT%'); 

これは意味があり問題を解決しますか?

ランA:ここ

関連する問題