$last = -1; foreach( $lines as $row ) { if( $row[0] == '' && $last == -1 ) { //error out, bitch //you can't have a non-item atached to a non-item, dude. } elseif( $row[0] != '' && $last == -1) { //starting a new item //-------------------- //find the category. If it doesn't exist, create it. $sql = "SELECT * FROM categories WHERE LCASE(name)=? OR LCASE(number)=?"; $values = array(strtolower($row[6]), strtolower($row[7])); $res = $db->qwv($sql, $values); $count = count($res); if( $count != 0 || $count != 1 ) { //you managed to name two different categories. You are teh suckorz. } else { $catid = -1; if( $count == 0 ) { $sql = "INSERT INTO categories (name, number) VALUES (?, ?)"; $values = array($row[6], $row[7]); $db->qwv($sql, $values); if( $db->stat() )
} else { echo "this is not an image file we support."; } $catid; $item_name = $_POST['item_name']; $item_desc = $_POST['item_desc']; $item_image = $file_name; $item_price = $_POST['item_price']; $item_preptime = $_POST['item_price']; $item_hasCookLevels = $_POST['item_hasCookLevels']; $item_ingredients = $_POST['item_ingredients']; $item_characteristics = $_POST['item_characteristics']; $item_category_name = $_POST['item_category_name']; $item_category_number = $_POST['item_category_number']; //split ingredients into ind ingredients $item_ingredient = explode(",", $item_ingredients); //same for chars $item_characteristic = explode(",", $item_characteristics); //if category does not exist, add it //find the category. If it doesn't exist, create it. $sql = "SELECT * FROM categories WHERE LCASE(name)=? OR LCASE(number)=?"; $values = array(strtolower($item_category_name), strtolower($item_category_number)); $res = $db->qwv($sql, $values); $count = count($res); if( !($count != 0 || $count != 1 ))