<?php
session_start();
require_once 'orders.php';
require_once 'user.php';
$orders = getOrders('');
$user = getUser($_SESSION['login']);
$id = $user['id'];
$orders_number = null;
while ($orders_number == null) {
for ($i=0; $i < count($orders); $i++) {
if (($user['id'] == $orders[$i]['user']) and ($orders[$i]['status'] == 'открыт')) {
$orders_number = $orders[$i]['id'];
echo $orders[$i]['id'];
}
}
if ($orders_number == null) {
require_once 'connect_db.php';
connectDB();
global $mysqli;
$mysqli->query ("INSERT INTO `orders` (`id`, `status`, `pay`, `user`, `name_z`, `family`, `patronymic`, `сountry`, `region`, `area`, `city`, `street`, `house`, `number`, `pindex`) VALUES (NULL, 'открыт', '0', '2', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0')");
closeDB();
}
}
// echo $orders_number;
?>