Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php // require_once './Domain.php';
- require_once './Navigacija.php';
- $Domain = new Domain();
- $file = fopen("Navigacijos.txt", "r");
- while (!feof($file)) {
- $line = fgets($file);
- $items = explode(";", $line);
- $item = new Navigacija($items[0], $items[1], $items[2], $items[3]);
- }
- //var_dump()
- fclose($file);
- ?>
- <?php
- $criteriaErr = "";
- $criteria = null;
- if ($_SERVER["REQUEST_METHOD"] == "POST") {
- if (empty($_POST["criteria"])) {
- $criteriaErr = "Name is required";
- } else {
- $criteria = test_input($_POST["criteria"]);
- }
- }
- function test_input($data) {
- $data = trim($data);
- $data = stripslashes($data);
- $data = htmlspecialchars($data);
- return $data;
- }
- ?>
- <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>">
- <input type="text" name="criteria" value="<?php echo $criteria; ?>">
- <span class="error">* <?php echo $criteriaErr; ?></span>
- <br><br>
- <input type="submit" name="submit" value="Submit">
- </form>
- <?php
- require_once './Domain.php';
- require_once './Navigacija.php';
- $Domain = new Domain();
- $file = fopen("Navigacijos.txt", "r");
- while (!feof($file)) {
- $line = fgets($file);
- $items = explode(";", $line);
- $item = new Navigacija($items[0], $items[1], $items[2], $items[3]);
- $Domain->insert_into_array($item);
- }
- function print_values($Domain) {
- for ($i = 0; $i < $Domain->get_count_elements(); $i++) {
- $object_to_array = ((array) $Domain->get_element($i));
- echo $object_to_array['brand'] . " " . $object_to_array['model'] . " " . $object_to_array['maps_number'] . " " . $object_to_array['price'] . "<br>";
- }
- }
- print_values($Domain);
- echo "<br>";
- echo "<br>";
- echo "<br>";
- //var_dump($Domain);
- if(isset($criteria)){
- for ($i = 0; $i < $Domain->get_count_elements(); $i++) {
- $object_to_array = ((array) $Domain->get_element($i));
- // var_dump($object_to_array);
- if ((int)$criteria > (int)$object_to_array['price']) {
- $Domain->delete_from_array($i);
- }
- } print_values($Domain);
- }
- fclose($file);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement