$sql="SELECT `".$what."` FROM `port_menu` WHERE `".$where."` LIKE '".$url."' "; */ $name = $_POST['select']; $text = $_POST['text']; $sub = $_POST['get_sub']; foreach ($_FILES['uploadfile']['name'] as $k => $v) { $u = new port_menu(); $u->current_menu($name, 'url', 'id'); $uploaddir = "../tree/portfolio/img/" . $u->url . "/"; $uploaddir2 = "tree/portfolio/img/" . $u->url; $uploaddir3 = "../tree/portfolio/img/" . $u->url . "/thumb/"; $apend = date('dHi') . rand(100, 1000); $uploadfile = $uploaddir . $apend . basename($_FILES['uploadfile']['name'][$k]); $uploadfile2 = $uploaddir3 . $apend . basename($_FILES['uploadfile']['name'][$k]); $file = $apend . basename($_FILES['uploadfile']['name'][$k]); $u->last_num($u->url, $sub); $last_num = $u->number + 1; $image = new SimpleImage(); $image->load($_FILES['uploadfile']['tmp_name'][$k]); $image->resizeToWidth(400); $image->save($uploadfile2); // Копируем файл из каталога для временного хранения файлов: if (move_uploaded_file($_FILES['uploadfile']['tmp_name'][$k], $uploadfile)) { echo "<h3>Файл успешно загружен на сервер</h3>"; if (isset($sub) && $sub != '') { $sql = "INSERT INTO `portfolio`(`category`, `file_name`, `capture`, `number`, `path`, `sub`) \nVALUES ('" . $u->url . "', '" . $file . "', '" . $text . "', '" . $last_num . "', '" . $uploaddir2 . "', '" . $sub . "')"; } else { $sql = "INSERT INTO `portfolio`(`category`, `file_name`, `capture`, `number`, `path`) \nVALUES ('" . $u->url . "', '" . $file . "', '" . $text . "', '" . $last_num . "', '" . $uploaddir2 . "')"; } if ($mysqli->query($sql) === TRUE) { echo "Запись добавлена успешно!";
$name = $row['url']; } //while } $sql_sub = "SELECT `id` FROM `portfolio` WHERE `sub` != '' AND `category` LIKE '" . $name . "'"; $result_sub = $mysqli->query($sql_sub); if ($result_sub->num_rows > 0) { $result_get_sub = $mysqli->query("SELECT * FROM `sub_cat` WHERE `category` LIKE '" . $name . "'"); echo "<select name=\"get_sub\"><option>...</option>"; while ($row = $result_get_sub->fetch_assoc()) { echo "<option value=" . $row['id'] . ">" . $row['name'] . "</option>"; } echo "</select>"; } $l = new port_menu(); $l->last_num($name, $sub); echo $l->number; break; case "edit_one_photo": $id = $_POST['id']; $img = new port_class(); $img->get_one_img("id", $id); $full_name = "/" . $img->path . "/" . $img->file_name; echo "<div id=\"image_div\">\n\t\t<img class=\"port_img\" src=\"" . $full_name . "\" alt=\"" . $img->file_name . "\">\n\t\t<textarea style=\"width:80%\" id=\"upt_capture\">" . $img->capture . "</textarea>\n\t\t<input type=\"hidden\" name=\"upd_id\" value=\"" . $id . "\">\n\t\t<input type=\"button\" value=\"Upd\" onclick=\"update()\">\n\t\t<input type=\"button\" value=\"Del\" onclick=\"delete_it()\">\n\t\t</div>"; break; case "upd_port_photo": echo $id = $_POST['id']; echo $capture = $_POST['capture']; $sql = "UPDATE `u802398134_magic`.`portfolio` SET `capture` = '" . $capture . "' WHERE `portfolio`.`id` ='" . $id . "';"; if ($mysqli->query($sql) === TRUE) { echo "Запись успешно обновлена!";