Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <form method="post" action="search_doctor.php" name="f1">
- <select required class="form-dropdown" name="area_name">
- <option value="" selected="selected" disabled hidden required>Меня
- интересует...</option>
- <option value="d1">Терапевт</option>
- <option value="d2">Стоматолог</option>
- <option value="d3">Окулист</option>
- <option value="d4">Хирург</option>
- </select>
- </div>
- <br>
- <section class="filter-wrapper">
- <div class="keyword-wrapper">
- <input type="text" id="keyword" autocomplete="off"
- placeholder="Введите название клиники" name="hospital_name"/>
- </div>
- <ul id="filter-select" class="filter-select no-value">
- </ul>
- </section>
- <br>
- <div class="form-group">
- <label class="label-color">Дата приема</label>
- <input type="date" name="cid" class="form-control timepicker"
- max="2979-12-31">
- </div>
- <div class="form-time">
- <label class="label-color">Время</label>
- <input type="time" value="09:00" class="form-control timepicker"
- name="time_from">
- </div>
- <div class="form-time">
- <label class="label-color">Время</label>
- <input type="time" value="18:00" class="form-control timepicker"
- name="time_to">
- </div>
- <br><br>
- <button type="submit" class="btn btn-primary btn-block"
- name="filter">Найти</button><br/>
- </div>
- </form>
- <?php
- require 'connect.php';
- function addWhere($where, $add, $and = true) {
- if ($where) {
- if ($and) $where .= " AND $add";
- else $where .= " OR $add";
- }
- else $where = $add;
- return $where;
- }
- if (!empty($_POST["filter"])) {
- $where = "";
- if ($_POST["area_name"]) $where = addWhere($where, "`area` >=
- '".htmlspecialchars($_POST["area_name"]))."'";
- if ($_POST["hospital_name"]) $where = addWhere($where, "`hospital` <=
- '".htmlspecialchars($_POST["hospital_name"]))."'";
- if ($_POST["date"]) $where = ???
- if ($_POST["time"]) $where = ???
- $sql = 'SELECT employee_name, employee_photo, e-mail, phone,
- hospital_name
- FROM (
- SELECT employee, area, hospital, schedule
- FROM employee, area, hospital, schedule
- )
- AS i
- LEFT JOIN group_attribute_hospital AS inst ON hospital_number =
- employee_number
- ';
- $second='employee_photo_main=0 ORDER BY employee_id DESC';
- if ($where) $sql .= " WHERE $where AND ".$second;
- else $sql .= " WHERE ".$second;
- }
- echo '<h1>Получили такой SQL запрос:</h1>'.$sql;
- $stmt = $pdo->prepare($sql);
- $stmt->execute($ids);
- $no=$stmt->rowCount();
- echo '<h2>В результате найдено: '.$no.' строк </h2>';
- $conn->close();
- ?>
Add Comment
Please, Sign In to add comment