Exemple #1
0
        $row++;
        // Skip blank rows
        if ($data[0] == '') {
            continue;
        }
        // Get title from CSV and Create Bag
        if ($row == 3) {
            $name = $data[0];
            echo "Create Bag: " . $name . "<br/>";
            $bagid = create_bag($name);
            if (!$bagid) {
                $bag = get_bag_by_name($name);
                $bagid = $bag['bagid'];
            }
        }
        // Skip Title Row
        if ($row < 4) {
            continue;
        }
        // Add Product to Bag (Create or Find Existing Product from inventory)
        import_bag_content($bagid, $data[0], $data[2], $data[3]);
        echo "Product: " . $data[0] . " | Quantity: " . $data[2] . " | Notes: " . $data[3] . "<br/>";
        /*
        		for ($c=0; $c < $num; $c++) {
                    echo $data[$c] . "<br />\n";
                }*/
    }
    fclose($handle);
}
?>
</pre>
Exemple #2
0
}
$row = 1;
if (($handle = fopen($path . $filename, "r")) !== FALSE) {
    while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
        $num = count($data);
        echo "<p> {$num} fields in line {$row}: <br /></p>\n";
        $row++;
        // Skip Heads Rows
        if ($row < 4) {
            continue;
        }
        // Skip blank Product rows
        if ($data[0] == '') {
            continue;
        }
        $product_name = $data[1];
        $quantity = $data[0];
        $notes = $data[2];
        $choice = $data[3] == "Y" ? '1' : '0';
        // Add Product to Bag (Create or Find Existing Product from inventory)
        import_bag_content($bagid, $product_name, $quantity, $notes, $choice);
        echo "Product: " . $product_name . " | Quantity: " . $quantity . " | Notes: " . $notes . "<br/>";
        /*
        		for ($c=0; $c < $num; $c++) {
                    echo $data[$c] . "<br />\n";
                }*/
    }
    fclose($handle);
}
?>
</pre>