1.
����������
год выхода: 2013
2.
���������
год выхода: 2005
3.
���� ������
год выхода: 2013
вот код
<?php
function search($words) {
$words = htmlspecialchars($words);
$words = mysql_real_escape_string($words);
$words = stripslashes($words);
$query_search = "";
$arraywords = explode(" ", $words);
foreach ($arraywords as $key => $value) {
if (isset($arraywords[$key - 1]))
$query_search .= " OR ";
$query_search .= "(`text_name` LIKE '%$value%')";
}
global $mysqli;
$query = "SELECT * FROM `movies` WHERE $query_search";
$mysqli = new mysqli ("127.0.0.1", "root", "", "users",);
$result_set = $mysqli->query($query);
$i = 0;
while($row = $result_set->fetch_assoc()) {
$results[$i] = $row;
$i++;
}
$result_set->close();
return $results;
}
if (isset($_GET["button_search"])) {
$words = $_GET['words'];
$results = search($words);
}
?>
<?php
if (($_GET["button_search"]) && (!empty($_GET["words"]))) {
$results = search($_GET["words"]);
if (count($results) != 0) {
for ($i = 0; $i < count($results); $i++) {
$number = $i + 1;
$link = "movies.php?id=".$results[$i] ["id"];
$title = $results[$i] ["text_name"];
$year = $results[$i] ["year"];
$images = $results[$i] ["images"];
include "block/search_item.php";
}
}
else echo '<div class="form-error"><b>Ничего не найдено!</b></div>';
}
else echo '<div class="form-error"><b>Вы задали пустой запрос!</b></div>';
?>