note 34807 deleted from ref.xml by didou

From: Date: Thu, 07 Aug 2003 09:49:07 +0000
Subject: note 34807 deleted from ref.xml by didou
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-53562@lists.php.net to get a copy of this message
Note Submitter: paul@ue.com.br ---- Create a MYSQL QUERY from a XML content... <? $content .= "<test>\n"; $content .= " <name>gh</name>\n"; $content .= " <cell>909</cell>\n"; $content .= "</test>\n"; $content .= "<test>\n"; $content .= " <name>ddd</name>\n"; $content .= " <cell>456756756745</cell>\n"; $content .= "</test>\n"; $content .= "<xxx>\n"; $content .= " <name>vbn</name>\n"; $content .= " <cell>343434</cell>\n"; $content .= " <aaa>3sdf34</aaa>\n"; $content .= " <bbb>3sdf34</bbb>\n"; $content .= " <ccc>3sdf34</ccc>\n"; $content .= "</xxx>\n"; preg_match_all ("/<(.*?)>(.*?)<\/\\1>/is", $content, $tag); while (list($k, $v) = each($tag[2])) { $names = $values = ""; preg_match_all ("/<(.*?)>(.*)<\/\\1>/i", $v, $out); while (list($j, $v2) = each($out[2])) { if ($names) $names .= ", "; $names .= $out[1][$j]; if ($values) $values .= ", "; $values .= "'".$out[2][$j]."'"; } if (($names) && ($values)) { echo $query = "INSERT INTO ".$tag[1][$k]." ($names) VALUES ($values)\n"; } } ?>

« previous php.notes (#53562) next »