-
Posts
24,563 -
Joined
-
Last visited
-
Days Won
822
Everything posted by Barand
-
None that haven't already been suggested
-
What is this doing in there? $sql = "TRUNCATE TABLE timeslot"; $db->query($sql); $dt1 = new DateTime("08:00:00"); $dt2 = new DateTime("08:15:00"); $di = new DateInterval('PT10M'); $dp = new DatePeriod($dt1, $di, new DateTime('18:00:00')); $sql = "INSERT INTO timeslot(start_time, end_time) VALUES (?,?)"; $smt = $db->prepare($sql); $smt->bind_param('ss', $st,$et); foreach ($dp as $d) { $st = $d->format('H:i'); $et = $dt2->format('H:i'); $dt2->add($di); $smt->execute(); } It generates the timeslot master table which is something that needs doing once (or if you decide to change the slots). Do you also intend to key in all the staff data every time you want to produce a calendar . IBM have a good motto - THINK! [edit] PS When you get current bookings you are now only interested in those bookings for the staff member with whom they want the appointment
-
You need $dt = $d->format('Y-m-d'); at the beginning of the function
-
I'd do the position updates in one query <?php $sql = "SELECT position, name FROM tableA ORDER BY position"; $res = $db->query($sql); while (list($pos,$name) = $res->fetch_row()) { echo "$pos | $name<br>"; } // // ROTATE THE POSITIONS // $sql = "UPDATE tableA JOIN (SELECT @max := (SELECT MAX(position) FROM tableA)) as getmax SET position = CASE position WHEN 1 THEN @max ELSE position-1 END"; $db->query($sql); ?> <form> <input type="submit" name="btnSub" value="Test"> </form>
-
see http://dev.mysql.com/doc/refman/5.6/en/string-types.html
-
Your syntax is all over the place. You have "SELECT .... FROM ... SELECT ... FROM ...". There should be only one SELECT and one FROM clause unless you have subqueries. You are referencing table alias "s" when there is no table in the FROM clause with that alias. You need to include the staff table as well as the patient table. You have "patent_id" instead of "patient_id". If you are using the same data as me then SELECT s.staff_id, s.lname, s.fname, t.timeslot_id, TIME_FORMAT(start_time, '%H:%i'), TIME_FORMAT(end_time, '%H:%i'), booking_id, p.lname, illness FROM timeslot t LEFT JOIN booking b ON t.timeslot_id = b.timeslot_id AND b.date = '$dt' LEFT JOIN patient p ON b.patient_id = p.patient_id LEFT JOIN staff s ON b.staff_id = s.staff_id ORDER BY t.start_time Note that you will require two versions of the booking form. If a patient is using the form then you would not show the patients' names and illness comments, just show which slots are booked or not and give an option to book a slot or cancel their own slot/s. If staff are viewing then they would need to see everything and be able to book/cancel for any patient
-
No, it won't even execute.
-
Make a copy of your data (just in case) then try UPDATE artist SET name = CONCAT_WS(' ',TRIM(SUBSTRING_INDEX(name,',',-1)),TRIM(SUBSTRING_INDEX(name,',',1))) WHERE INSTR(name,',');
-
You could call a js function when the link is clicked which then uses AJAX to update the db table
-
I'd do the calendar to show, for the selected staff member, which days they are available, which days are part-booked and which are fully booked then do the booking form for the day selected You need to query the booking, staff_sched and holiday tables
-
This is the function that I used. You can pass it the currently selected staff member id ($sid) to show the currently selected one function staffOpts($db, $sid=0) { /******************************************* * Create the options for the staff menu ********************************************/ $staffOpts = "<option value=''>- select doctor/nurse -</option>\n"; $sql = "SELECT staff_id, CONCAT_WS(' ',title,fname,lname) as name FROM staff s INNER JOIN staff_type t ON s.staff_type = t.staff_type_id WHERE t.medical = 1 ORDER BY title , lname"; $res = $db->query($sql); while (list($i, $n) = $res->fetch_row()) { $sel = $i==$sid ? 'selected="selected"' : ''; $staffOpts .= "<option $sel value='$i'>$n</option>\n"; } return $staffOpts; } So the query returns +----------+------------------+ | staff_id | name | +----------+------------------+ | 2 | Dr Jane Doe | | 1 | Dr Boris Johnson | | 3 | Mrs Molly Malone | +----------+------------------+ then Appointment with: <select name="sid" id="sid"> <?=staffOpts($db, $staffID)?> </select><br><br>
-
These are the tables I have in my test db mysql> show tables; +---------------+ | Tables_in_db | +---------------+ | booking | | holiday | | patient | | patient_notes | | sched_hours | | staff | | staff_type | | timeslot | | weekday | +---------------+
-
The calendar code and booking form will need rewriting to take into account which member of staff the appointment is to be with and when they are available in terms of days and timeslots (from the holiday and schedhours tables) booking table shown below. The staff and patients are the users. You have tables for those.
-
change line 44 $res = $db->query($sql); to $res = $db->query($sql) or die( $db->error );
-
The sched_hours table will only contain records where the staff member is available whereas the form requires every day of the week for every staff member. As you can see from the query, this is ensured by the CROSS JOIN. FROM staff CROSS JOIN weekday
-
-
Neither am I. It worked when it left the shop but I don't know what you have changed. I wonder? I use a weekday table to define all the days of the week CREATE TABLE `weekday` ( `dow` int(11) NOT NULL, `abbrev` varchar(2) DEFAULT NULL, PRIMARY KEY (`dow`) ); +-----+--------+ | dow | abbrev | +-----+--------+ | 1 | Su | | 2 | Mo | | 3 | Tu | | 4 | We | | 5 | Th | | 6 | Fr | | 7 | Sa | +-----+--------+
-
That's because you have $options[$query_data["adate"]] = $query_data["adate"]; when you should have $options[$query_data["ndate"]] = $query_data["adate"];
-
If you use the revised model that I gave you (attached) then you can use this form and update script to populate with the timeslots that each staff is normally available each day. To produce the calendar and booking form you would also take holidays into account. cal_sched_form.php cal_sched_updt.php
-
If you use my query to get the options and then process those options as did in your earlier post foreach ($options as $key => $val) then you should get eg <option value='2015-01'>Jan 2015</option>
-
The query I gave you was for the date options, so selecting would give a value like "2015-02" (yy-mm). You would then query your films for those WHERE fileDate LIKE '$date%' (assuming fileDate is a DATE field in format yyyy-mm-dd)
-
Even though it was only for a day
-
$yesterday = strtolower((new DateTime('yesterday'))->format('D'));
-
Is this what you are looking for? SELECT YEAR(addDate) as yr , COUNT(DISTINCT a.personID) as tot FROM stu_acad_cred s LEFT JOIN application a ON s.stuID = a.personID AND a.startTerm = '12/FA' GROUP BY yr;
-
I'd use a query like this to build the option array $query_disp="SELECT DISTINCT DATE_FORMAT(FileDate, '%b %Y') as adate ,DATE_FORMAT(FileDate, '%Y-%m') as ndate FROM DayMovie ORDER BY FileDate"; $result_disp = mysql_query($query_disp, $conn); $options = array(); while ($query_data = mysql_fetch_array($result_disp)) { $options[$query_data["ndate"]] = $query_data["adate"]; }