Skip to content
Advertisement

Displaying data from mysql from datepicker

I need some suggestions/help with my code. Code:

JavaScript

JavaScript

When i select dateFrom and dateTo, everything works like a charm and form shows me records from db between two dates, but what i need: I want to display data for specific user. Example: I choose Employee Name > Micheal from and form shows me data for Micheal only, when i choose David, shows only for David not all employees. How can i do this?

I have database with 3 tables: employees, accounts and customers.

Under employees i have columns: id, username, workdate, startdate and enddate.

Advertisement

Answer

  1. First: You should add a select option to your form, and on each row set the id as value.

  2. Second: You need to get the id with: $id = $_POST[‘id’];

  3. Third: Finally, you need to change your query to:

SELECT * FROM employees WHERE workdate BETWEEN ‘”.$fromDate.”‘ AND'”.$endDate.”‘ AND id = $id

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement