From 5468b1d2860f8173bf9ab0050803fb54beff40ed Mon Sep 17 00:00:00 2001 From: stas Date: Mon, 27 May 2024 11:40:02 +0300 Subject: [PATCH] ver.0.2 --- Information.txt | 5 ----- Search.php | 2 +- form.php | 6 ++++++ info.php | 22 ++++++++++++++++++---- search_result.php | 36 ++++++++++++++++++++++++++++++++++++ 5 files changed, 61 insertions(+), 10 deletions(-) create mode 100644 search_result.php diff --git a/Information.txt b/Information.txt index 99bb000..8c4ef37 100644 --- a/Information.txt +++ b/Information.txt @@ -7,8 +7,3 @@ Зайцев;Федор;Александрович;2014-12-22;Мужчина;+7;6667774441;asert@mail.ru Иванов;Петр;Михайлович;2002-03-11;Мужчина;+7;1111111111;asert@mail.ru Иванов;Роман;Сергеевич;2002-03-11;Мужчина;+7;1111111111;ple.anastasiya@gmail.com -Билай;Станислав;Романович;4444-04-04;Мужчина;+7;9493761924;stasbilay02@yandex.ru -Билай;Станислав;Романович;4444-04-04;Мужчина;+7;9493761924;stasbilay02@yandex.ru -Билай;Станислав;Романович;4444-04-04;Мужчина;+7;9493761924;stasbilay02@yandex.ru -Билай;Станислав;Романович;4444-04-04;Мужчина;+7;9493761924;stasbilay02@yandex.ru -Билай;Станислав;Романович;4444-04-04;Мужчина;+7;9493761924;stasbilay02@yandex.ru diff --git a/Search.php b/Search.php index 2b7d09a..1657120 100644 --- a/Search.php +++ b/Search.php @@ -1,5 +1,5 @@ '; echo $form; + +/* $formSearch = + '
+

+ +
';*/ \ No newline at end of file diff --git a/info.php b/info.php index 28dc823..ca1aa41 100644 --- a/info.php +++ b/info.php @@ -5,7 +5,7 @@ namespace src; use Information; require_once "src/Information.php"; -require_once "Search.php"; +/*require_once "Search.php";*/ $fileName = "Information.txt"; $fileModeOpen = "a"; @@ -21,15 +21,29 @@ $file = fopen($fileName, $fileModeOpen); fwrite($file, $string); fclose($file); -$file = fopen($fileName, "r"); +$formSearch = + '
+

+ +
'; + +echo $formSearch; + +/*$file = fopen($fileName, "r"); $arrKey = array('surname', 'name', 'patronymic', 'dateOfBirth', 'gender', 'countryCode', 'phoneNumber', 'email'); $parsingArray = array(); +echo "
";
+print_r($_REQUEST);
+
+$forSearch = $_REQUEST['result_search'];
+
 while (!feof($file)) {
     $str = fgets($file);
-    if(search($str, '/\b(иванов)\b/ui')){
+    //if(search($str, '/\b(иванов)\b/ui')){
+    if(search($str, $forSearch)){
         $array = array_combine($arrKey, explode(";", $str));
         $obj = new Information();
         $obj->load($array);
@@ -37,6 +51,6 @@ while (!feof($file)) {
     }
 }
 echo "
";
-print_r($parsingArray);
+print_r($parsingArray);*/
 
 require "table.php";
\ No newline at end of file
diff --git a/search_result.php b/search_result.php
new file mode 100644
index 0000000..5a5ed2f
--- /dev/null
+++ b/search_result.php
@@ -0,0 +1,36 @@
+";
+print_r($_REQUEST);
+
+$forSearch = '/\b(' . $_REQUEST['result_search'] . ')\b/ui';
+
+while (!feof($file)) {
+    $str = fgets($file);
+    if(search($forSearch, $str)){
+    //if(search($str, $forSearch)){
+        $array = array_combine($arrKey, explode(";", $str));
+/*        echo "
";
+        print_r($array);*/
+        $obj = new Information();
+        $obj->load($array);
+        $parsingArray[] = $obj;
+    }
+}
+
+echo "
";
+print_r($parsingArray);
\ No newline at end of file