Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- user_id | login | email
- ---------- | ------------- | ------------
- 1 | AD1 | email1@email.com
- 2 | AD2 | email2@email.com
- id | user_id | dtfrom | dtto
- ---------- | ------------- | ------------ ------------
- 1 | AD1 | 2017-12-12 | 2017-12-12
- 2 | AD1 | 2017-12-13 | 2017-12-13
- 3 | AD2 | 2017-12-20 | 2017-12-20
- {
- "login":"AD1",
- "email":"email1@email.com",
- "movement":
- [
- {
- "dtfrom":"2017-12-12",
- "dtto":"2017-12-12"
- },
- {
- "dtfrom":"2017-12-13",
- "dtto":"2017-12-13"
- }
- ]
- }
- {
- "login":"AD1",
- "email":"email1@email.com",
- "0":
- {
- "dtfrom":"2017-12-12",
- "dtto":"2017-12-12"
- },
- "1":
- {
- "dtfrom":"2017-12-13",
- "dtto":"2017-12-13"
- }
- }
- <?php
- $connect = mysqli_connect("", "", "", "");
- global $connect;
- if (isset($_POST['login']))
- {
- $login = $_POST['login'];
- $sql = "SELECT * FROM users WHERE login='$login'";
- $result = mysqli_query($connect, $sql);
- if ($result && mysqli_num_rows($result) > 0) {
- while ($row = mysqli_fetch_array($result)) {
- $login_db = $row['login'];
- $email_db = $row['email'];
- $output = array('login' => $login_db, 'email' => $email_db);
- $sql2 = "SELECT * FROM movement WHERE user_id='$login_db'";
- $result2 = mysqli_query($connect, $sql2);
- if ($result2 && mysqli_num_rows($result2) > 0) {
- while ($row2 = mysqli_fetch_array($result2)) {
- $dtfromdb = $row2['dtfrom'];
- $dttodb = $row2['dtto'];
- $output[] = array('dtfrom'=> $dtfromdb,'dtto'=> $dttodb);
- }
- } else {}
- }
- echo json_encode($output);
- mysqli_free_result($result);
- }
- else { echo 'not found'; }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement