Advertisement
Guest User

Untitled

a guest
Jan 19th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. $xml=simplexml_load_file("URL") or die("Error: Cannot create object");
  2. foreach ($xml->programs->products->product as $product);
  3. foreach ($xml->programs->products->product->product_info->price as $price);
  4.  
  5. $insert = 'INSERT INTO BBB (price) VALUES (?)';
  6. $insertStmt = $dbconnection->prepare($insert);
  7. foreach ($product as $row) {
  8. $insertStmt->bind_param('s', $price);
  9. }
  10.  
  11. $insertStmt->execute();
  12.  
  13. echo "New records created successfully";
  14.  
  15. $xml=simplexml_load_file("URL") or die("Error: Cannot create object");
  16.  
  17. $insert = 'INSERT INTO BBB (price) VALUES (?)';
  18. $insertStmt = $dbconnection->prepare($insert);
  19. foreach ($tags as $key=>$val) {
  20. if ($key == "product") {
  21. $dcprice = $key->product_info->price;
  22. $productranges = $val;
  23. for ($i=0; $i < count($productranges); $i+=2) {
  24. $offset = $productranges[$i] + 1;
  25. $len = $productranges[$i + 1] - $offset;
  26. $price[] = $dcprice(array_slice($values, $offset, $len));
  27. }
  28. } $insertStmt->bind_param('s', $price);
  29. $insertStmt->execute();
  30. }
  31.  
  32. echo "New records created successfully";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement