Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $servername = "d58093.mysql.zone.ee";
- $username = "d58093sa114985";
- $password = "";
- $dbname = "d58093_bredencom";
- // Create connection
- $conn = mysqli_connect($servername, $username, $password, $dbname);
- // Check connection
- if (!$conn) {
- die("Connection failed: " . mysqli_connect_error());
- }
- $xml = simplexml_load_file("https://www.bredenkids.com/erply/suurused.php");
- //$queryID_s1 = 'SELECT product_id FROM jk2031_otp_option_value WHERE child_option_value_id IN (76, 75, 81, 123) ORDER BY product_id ASC ';
- $querys[] = 'SELECT product_id FROM jk2031_otp_option_value WHERE child_option_value_id IN (105, 117,81, 82, 75, 76, 116, 77, 109) ORDER BY product_id DESC';
- $querys[] = 'SELECT product_id FROM jk2031_otp_option_value WHERE child_option_value_id IN (99, 118, 81, 77, 109, 110, 78) ORDER BY product_id DESC'
- foreach ($querys as $sql) {
- $result = mysqli_query($conn, $sql);
- if (mysqli_num_rows($result) > 0)
- {
- // output data of each row
- while($row = mysqli_fetch_assoc($result))
- {
- $products[] = $row['product_id'];
- }
- }
- /* käime läbi kõik tooted mis on XMLis */
- foreach ($xml->products->children() as $product)
- {
- if (empty ($products)) exit;
- if (in_array($product->product_id, $products))
- {
- /* kui kogus on 0 või väiksem siis lähme edasi loopiga */
- if ($product->sizes->size->attributes()->qty <= 0)
- {
- continue;
- }
- else
- {
- $product_id = (STRING) $product->sizes->size->attributes()->product_id;
- $otp_id = (STRING) $product->sizes->size->attributes()->otp_id;
- $sql = 'INSERT INTO jk2031_product_filter(product_id, filter_id) VALUES("' . $product_id . '", "' . $otp_id .'")';
- mysqli_query($sql);
- }
- }
- }
- }
- mysqli_close($conn);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement