jmahdi Posted March 22, 2012 Share Posted March 22, 2012 Hi there: what i'm trying to do is i want to get the contents of heading and text_details and merge them together before adding them as one entry into database: <div class="heading"><p> Second quote: </div><div class=text_details> <p> Satan's substitute for repentance is the man's rationalization of evil. <p></b></div> my code looks s/thing like this: foreach( $dom->getElementsByTagName('div') as $div ) { foreach( $div->attributes as $attributes ) { if( strtolower($attributes->name) == 'class' ) { if( strtolower($attributes->value) == 'heading' || strtolower($attributes->value) == 'text_details') { $quote = $div->textContent; $clean_quote = mysql_real_escape_string($quote); echo "the quote is: " . $clean_quote . "<br />"; mysql_query("INSERT INTO quotes (quote) VALUES ('$clean_quote')")or die(mysql_error()); } } } } when i do this obviously i get: Second quote of the day entered into a field by itself and Satan's substitute for repentance is the man's rationalization of evil. into another field...how to make them one!?? thanks in advance Link to comment https://forums.phpfreaks.com/topic/259493-using-domdocument-or-else-to-merge-contents-of-different-elements/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.