CREATE TABLE IF NOT EXISTS `product_country` (
`product_id` int(11) NOT NULL,
`country_id` int(11) NOT NULL,
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ;
CREATE TABLE IF NOT EXISTS `product_shop` (
`product_id` int(11) NOT NULL,
`shop_id` int(11) NOT NULL,
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ;
CREATE TABLE IF NOT EXISTS `product_section` (
`product_id` int(11) NOT NULL,
`section_id` int(11) NOT NULL,
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ;
CREATE TABLE IF NOT EXISTS `product_category` (
`product_id` int(11) NOT NULL,
`category_id` int(11) NOT NULL,
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ;
CREATE TABLE IF NOT EXISTS `product_subcategory` (
`product_id` int(11) NOT NULL,
`subcategory_id` int(11) NOT NULL,
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ;
products
удалить shop_id
, country_id
и subcategory_id
? products_countries (product_id, country_id)
а таблицу products_countries_categories (product_id, country_id, categry_id,)
Что бы можно было выводить не все категории если пользователь выберет определенную страну а только те категории в которых есть товары которые относятся к указанной стране? products_countries (product_id, country_id)
а таблицу products_countries_categories (product_id, country_id, categry_id,)
Что бы можно было выводить не все категории если пользователь выберет определенную страну а только те категории в которых есть товары которые относятся к указанной стране? CREATE TABLE IF NOT EXISTS `country` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(256) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
CREATE TABLE IF NOT EXISTS `shop` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(256) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
CREATE TABLE IF NOT EXISTS `product_coutry` (
`product_id` varchar(256) NOT NULL,
`country_id` int(11) NOT NULL,
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ;
CREATE TABLE IF NOT EXISTS `sections` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(256) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
CREATE TABLE IF NOT EXISTS `categories` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(256) NOT NULL,
`section_id` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
CREATE TABLE IF NOT EXISTS `subcategory` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(256) NOT NULL,
`category_id` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
CREATE TABLE IF NOT EXISTS `products` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(256) NOT NULL,
`description` varchar(256) NOT NULL,
`url` varchar(256) NOT NULL,
`price` double NOT NULL,
`shop_id` int(11) NOT NULL,
`created` datetime NOT NULL,
`modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
[06-Sep-2022 05:15:00 UTC] PHP Notice: Undefined index: username in /home/patedfrb/public_html/affiliateproduct/do_register.php on line 7
[06-Sep-2022 05:15:00 UTC] PHP Notice: Undefined index: username in /home/patedfrb/public_html/affiliateproduct/do_register.php on line 17
[06-Sep-2022 05:15:00 UTC] PHP Fatal error: Uncaught PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'username' cannot be null in /home/patedfrb/public_html/affiliateproduct/do_register.php:18
Stack trace:
#0 /home/patedfrb/public_html/affiliateproduct/do_register.php(18): PDOStatement->execute(Array)
#1 {main}
thrown in /home/patedfrb/public_html/affiliateproduct/do_register.php on line 18
<?php
require_once __DIR__.'/boot.php';
// Проверим, не занято ли имя пользователя
$stmt = pdo()->prepare("SELECT * FROM `admin` WHERE `username` = :username");
$stmt->execute(['username' => $_POST['username']]);
if ($stmt->rowCount() > 0) {
flash('Это имя пользователя уже занято.');
header('Location: /'); // Возврат на форму регистрации
die; // Остановка выполнения скрипта
}
// Добавим пользователя в базу
$stmt = pdo()->prepare("INSERT INTO `admin` (`username`, `password`) VALUES (:username, :password)");
$stmt->execute([
'username' => $_POST['username'],
'password' => password_hash($_POST['password'], PASSWORD_DEFAULT),
]);
header('Location: login.php');
<div class="container w-100 p-3">
<div class="row justify-content-center">
<div class="col-4">col-4</div>
<div class="col-8">
<form class="row justify-content-center">
<div class="col-8">
<label for="inputPassword2" class="visually-hidden">URL</label>
<input type="text" class="form-control" id="inputUrl" placeholder="Url">
</div>
<div class="col-auto">
<button type="submit" class="btn btn-primary mb-3">Open</button>
</div>
</form>
</div>
</div>
</div>
<div class="col-8">
public class MaxArrayValue {
int[] numbers = {1, 7, 5, 2, 4};
public static int getMaxNumber(int[] numbers) {
//Write code below this line
int max = 1;
for(int i = 0; i < numbers.length; i++) {
System.out.println(numbers[i]);
}
return numbers[i];
}
}
i
я получаю индекс массива private void PutDataIntoRecyclerView(List<CategoryModel> categoryList) {
CategoryAdapter categoryAdapter = new CategoryAdapter(getContext(), categoryList);
binding.recyclerMain.setLayoutManager(new LinearLayoutManager(getContext()));
binding.recyclerMain.setAdapter(categoryAdapter);
}
interface IItemClick {
public void onClick(int id);
}
IItemClick itemClick
сразу предлагает импортировать класс HomeFragment. После импорта класса в конструкторе следующая ошибка
А у таблицы
products
удалитьshop_id
,country_id
иsubcategory_id
?