2 questions, MySql and iframe

Status
Not open for further replies.

abhorrent

New member
Feb 6, 2008
783
13
0
Illinois
There are unrelated questions but thought I'd combine them into one post.

First the MySql question...
I have a site with about 1000 links on it, all unique. What I want to do is a search and replace in mysql to change or remove them. So basically each field would look like this...
Code:
content, content, content, content
, content, content, content, content etc..
<a href="mylink.com">Link</a>
Since each link is unique I'd want to say "Take everything that starts with "<a href", all the stuff in between and ends with "< / a >" and replace it.

Here is the query I've been trying to modify and use but haven't been able
to get it to work.
Code:
update  content set content_detail = replace(content_detail,'replace everything between tags','with this');
I don't think that's correct but my googling has proven fruitless to this point.

***********************************************

The second question is my iframe question.
I use them for some things but occasionally they redirect to the site I'm framing. Is there a way to force the page to load in the iframe?
Again I've tried some of the "solutions" I found but none seem to work, unless I'm doing it wrong.

This is the complete code of my page...
Code:
<?php include(TEMPLATEPATH.'/header2.php'); ?>
<div id="content">
   <iframe frameborder="0" src="<?php echo get_post_meta($post->ID, "offer", true); ?>" width="1024px" height="768px" MARGINWIDTH="0" MARGINHEIGHT="0" SCROLLING="no"></iframe>
       </div>
I've spent way too much time on what are probably simple things that I just can't seem to figure out.
Any help would be appreciated.
 


Mysql AFAIK can't do what you want (at least not in a straightforward way) as regexp backreferences can't be used as an update value. You have php at your disposal, there's many examples of preg_replace to do exactly what you want.

As for the iframe, I think error_log('offer: '.get_post_meta($post->ID, "offer", true)); would give you insight into why your iframe misbehaves on occasion, if offer: is what you expect in the error log then firebug would probably help you diagnose. If you really want to reload it or force it to load something some js along the lines of (document.getElementsByTagName('iframe'))[0].src = 'http://url' should do the thing assuming in that example that's the first iframe.
 
I saw a bunch of preg_replace stuff in my searches, couldn't get that to work either. Probably just me not doing it right.

For the iframe I'm not sure I understand your response. The '('offer: '.get_post_meta($post->ID, "offer", true));' is using a custom field in wordpress for the url of the site.

So basically this...
Code:
<?php include(TEMPLATEPATH.'/header2.php'); ?>
<div id="content">
   <iframe frameborder="0" src=[COLOR=Yellow]"<?php echo get_post_meta($post->ID, "offer", true); ?>"[/COLOR] width="1024px" height="768px" MARGINWIDTH="0" MARGINHEIGHT="0" SCROLLING="no"></iframe>
       </div>
renders this...
Code:
<?php include(TEMPLATEPATH.'/header2.php'); ?>
<div id="content">
   <iframe frameborder="0" src=[COLOR=Yellow]"whateverurlIenter.com"[/COLOR] width="1024px" height="768px" MARGINWIDTH="0" MARGINHEIGHT="0" SCROLLING="no"></iframe>
       </div>
Even if I code the url into the template, it still redirects.
Oh well, neither one is the end of the world. I'll just deal with it.
 
Status
Not open for further replies.