$sql = "SELECT * FROM название таблицы WHERE DATE = ?";
$result = $conn->execute_query($sql, [$dateNew]);
$usersArray = $result->fetch_all(MYSQLI_ASSOC);
SELECT * FROM название таблицы WHERE DATE BETWEEN ? AND ?
"$dateNew 00:00:00"
и "$dateNew 23:23:59"
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
} else {
echo "Connected successfully";
}
ini_set('display_errors', 1);
To use a literal instance of a special character in a regular expression, precede it by two backslash (\) characters. The MySQL parser interprets one of the backslashes, and the regular expression library interprets the other.
Я только недавно начал изучать программирование
<?=$contacts['filial']?>
- это говнокод и дыра в безопасности. В любых данных, выводимых в HTML, должны экранироваться спецсимволы HTMLfunction listContactsByDepartment ($pdo){
$sql = "SELECT
t3.department, -- обращаем внимание на эту строчку. Она должна быть первой
t1.id,
t1.full_name,
t1.email_user,
t1.tel_number,
t2.filial,
t3.department_email,
t4.position,
t5.number
FROM contact_work AS t1 INNER JOIN filial_work AS t2 ON t1. id_filial = t2.id
INNER JOIN department_work AS t3 ON t1. id_department = t3.id
INNER JOIN position AS t4 ON t1. id_position = t4.id
INNER JOIN number_work AS t5 ON t1. id_number = t5.id
ORDER BY `t2`.`filial` ASC , `t3`.`department` DESC ";
return $pdo->query($sql)->fetchAll(PDO::FETCH_GROUP); # Обращаем внимание на эту константу
}
$contacts = listContactsByDepartment ($pdo);
<?php foreach($contacts as $department_title => $department_contacts): ?>
<tr>
<td colspan=10><?=htmlspecialchars($department_title) ?>
<tr>
<?php foreach($department_contacts as $row): ?>
<tr>
<td><?=htmlspecialchars($row['filial']) ?></td>
...
</tr>
<?php endforeach ?>
<?php endforeach ?>
$query = "UPDATE `users` SET `address`= ?,`phone_number`=? WHERE email=?";
$params = [
$address,
$phone_number,
$email,
];
$stmt = $pdo->prepare($query);
$stmt->execute($params);
$id = $_SESSION['id'];
$sql = "INSERT INTO zakaz (iduser,idkat) SELECT iduser, idkat FROM corzina WHERE iduser=?";
$stmt = $bd->prepare($sql);
$stmt->bind_param('i', $id);
$stmt->execute($res);
Хотелось бы понять как можно ускорить поиск товаров в базе данных MySQL, когда приходится использовать большое количество Id категорий в in.
error_reporting(E_ALL);
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
ini_set('display_errors',1);
ini_set('display_errors', 0);
ini_set('log_errors', 1);
$this->database()->query('UPDATE ' . $this->database()->getTable('ad') . ' SET view = 0 WHERE ad_id = 34');
$this->database()->query('UPDATE ' . $this->database()->getTable('ad') . ' SET view = 1 WHERE ad_id = 35');
$this->database()->query('UPDATE ' . $this->database()->getTable('ad') . ' SET view = 2, amount=466 WHERE ad_id = 36');
ssh user@host.com
mysql -u -p -h -P
ssh -N -f -L 3366:127.0.0.1:3306 user@host.com