hellp with xml and mysql php script
can someone help the prob is this is part of my script the script sends to a data base ok but send all the products_id ok but the products_model code are the same
products_id products_model
12796 0 bb2018
12805 0 bb2018
13719 0 bb2018
this i part of the xml file this to show the stucher
Code XML:
<STOREITEMS>
<CREATED value="Fri Feb 22 1:01:02 GMT 2013">
<CATEGORY id="442" name=" > test">
<PRODUCT ITEM="12796">
<NAME>test1</NAME>
<MODEL>bb2018</MODEL>
<PRICE>2.28</PRICE>
<RRP>3.99</RRP>
<THUMB>bb2018s.jpg</THUMB>
<IMAGE>bb2018.jpg</IMAGE>
<DESCRIPTION>
Code PHP:
foreach($xml->xpath('//PRODUCT/@ITEM') as $productitemid){
foreach($xml->CREATED->CATEGORY->PRODUCT as $product)
mysql_query("INSERT INTO products (products_id,products_model) VALUES ('$productitemid','$product')");
}
It only reads the frist category
i have many categorys in my xml how do i get to read all the products it only reads the frist category
thanks
Code PHP:
foreach($xml->CREATED->CATEGORY as $product){
$atts = $product->PRODUCT->attributes();
$productitemid = $atts['ITEM'];
$title = $product->MODEL;
$rrp = $product->RRP;
$productsdescription = $product->DESCRIPTION;
$prodname = $product->NAME;
echo $productitemid.' - ' ;
// echo $product->id.' - ';
mysql_query("INSERT INTO products (products_id,products_model,products_price,products_status) VALUES ('$productitemid','$title','$rrp','1')");
mysql_query("INSERT INTO products_description (products_id,products_name,products_description) VALUES ('$productitemid','$prodname','$productsdescription')");
}