You are here: Re: Extract Content Between Style Tags with Preg and PHP « All PHP « IT news, forums, messages
Re: Extract Content Between Style Tags with Preg and PHP

Posted by ameshkin on 09/10/06 05:04

OK, here is the problem now.... I'm sure its an easy answer, but I
can't seem to figure out the answer. Check this code out

mysql_select_db($database_piggybank, $piggybank);

echo '<textarea name="style" cols="50" rows="5" onClick="
this.focus();this.select()">';
foreach($match[0] as $div) {
echo $div;


echo "</textarea>";

$sql = mysql_query("INSERT INTO `layoutsQ` ( `auto` , `site` , `cat` ,
`code` , `name` )
VALUES (
'', 'myspace', '$cat', '$div', '$name'
)",$piggybank) or die("database busy");

}

All I am trying to do, is simply throw the $div into a database. But
what happens is, THREE Lines get put into the database. One for each
$div. I want all the content in the text area to be thrown into ONE
new row into the database. Pretty simple I bet, but I just have not
been able to google the answer to this. ha ha















ameshkin wrote:
> Holy shit it works...but, I will test this some more. What if there
> is more than one instance of the style tag. Do i have to do something
> like this?
>
> foreach($match[0] as $div) {
> echo $div;
> }
>
> and for the second one
>
> foreach($match[1] as $div) {
> echo $div;
> }
>
> I will experiment a little. If you can't tell, i only have about 6
> months of PHP experience. Pretty much self taught. Thank yo sooo
> much, you save dme hours of HORRIBLE regular expression reading and
> figuring out!
>
>
> Rik wrote:
> > Rik wrote:
> > > ameshkin wrote:
> > >> This script I wrote works with tables, td's and div's, but not with
> > >> style tags. Can anyone figure out the regular expression for finding
> > >> <style> tags. The trick is that sometimes its not just <style> Its
> > >> <style type="text/css">
> > >>
> > >> Basically, i want to take the information in between the style
> > >> content from any url
> > >>
> > >
> > > Well, for stasters it's closed with </style>, not <\style>....
> > >
> > >
> > > preg_match_all('|<style[^>]*?>(.*?)</style>|si',$html,$matches);
> >
> > preg_match_all('|<style[^>]*>(.*?)</style>|si',$html,$matches);
> > is better here...
> >
> > --
> > Rik Wasmus

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация