<tbody>
<?php
$link1 = mysqli_connect($db_host, $db_user, $db_password, $db_database)
or die("Ошибка " . mysqli_error($link1));
$query1 ="SELECT * FROM categorys WHERE id='$id' ";
$result1 = mysqli_query($link1, $query1) or die("Ошибка " . mysqli_error($link1));
if (mysqli_num_rows($result1) > 0) {
$query1 ="SELECT * FROM tovar WHERE products_id='$id' ";
$result1 = mysqli_query($link1, $query1) or die("Ошибка " . mysqli_error($link1));
if (mysqli_num_rows($result1) > 0) {
$row1 = mysqli_fetch_array($result1);
do {
echo '
<tr>
<td class="name" >'.$row1["tovar"].'</td>
<td>'.$row1["many"].'</td>
<td><a class="cart" data-toggle="modal" data-target="#feedbackFormModal" ><img src="img/cart.png" /></a></td>
</tr>
';
}
while ($row1 = mysqli_fetch_array($result1));
} }
?>
</tbody>
"use strict";
let modal = document.querySelector(".modal");
let table = document.querySelector("table");
table.addEventListener("click", (e) => {
let item = e.target;
if (!item.classList.contains("cart"))
return false;
let tr = item.parentElement.parentElement;
let name = tr.querySelector(".name");
let email = tr.querySelector(".email");
modal.querySelector("input[name='name']").value = name.textContent;
modal.querySelector("input[name='email']").value = email.textContent;
modal.style.display = "block";
});
$link = mysqli_connect($db_host, $db_user, $db_password, $db_database)
or die("Ошибка " . mysqli_error($link));
$query ="INSERT INTO categorys ( category, brand ) VALUES ( '$brand', '$brands' )";
$result = mysqli_query($link, $query) or die("Ошибка " . mysqli_error($link));
$id = mysqli_insert_id($link);