-
Posts
24,612 -
Joined
-
Last visited
-
Days Won
834
Everything posted by Barand
-
How can I generate a unique Doctor Appointment ID
Barand replied to sohailsaif's topic in PHP Coding Help
OK, instead of phoning I keep trying online all morning until a suitable timeslot is offered to me. I have now wasted an hour of my life. Alternatively I arrive late and sit there for hours waiting for an appointment slot. This is not a great user experience. Having established which date I want and which doctor I want to see, why don't you then offer me a list of available times so I can select one that suits me?- 8 replies
-
- php
- javascript
-
(and 1 more)
Tagged with:
-
How can I generate a unique Doctor Appointment ID
Barand replied to sohailsaif's topic in PHP Coding Help
So I ring the doctor's to arrange an appointment and the next timeslot is 12:15. Unfortunately it is impossible for me to get there before 2pm. Now what happens? Do I keep ringing back until the next available slot is 2:00 then take the appointment?- 8 replies
-
- php
- javascript
-
(and 1 more)
Tagged with:
-
You need to include an email header to tell it that the content is HTML
-
You need to call mysqli_query before you can fetch any rows
-
Put it in code tags with decent formatting applied and someone may look at it.
-
How can I generate a unique Doctor Appointment ID
Barand replied to sohailsaif's topic in PHP Coding Help
After some experimenting, here's another option for you but it will only work with a MyISAM table Define a multi-column primary key so that the auto_incrementing column comes last (doctor_id, date, appointment_id) CREATE TABLE `appointment` ( `appointment_id` int(11) NOT NULL AUTO_INCREMENT, `doctor_id` int(11) NOT NULL DEFAULT '0', `patient_id` varchar(45) DEFAULT NULL, `app_date` date NOT NULL DEFAULT '0000-00-00', `app_time` time DEFAULT NULL, PRIMARY KEY (`doctor_id`,`app_date`,`appointment_id`) ) ENGINE=MyISAM ; Also note I have separated date and time so the date can be used in the key without the time. So in the table I now have +----------------+-----------+------------+------------+----------+ | appointment_id | doctor_id | patient_id | app_date | app_time | +----------------+-----------+------------+------------+----------+ | 1 | 1 | 3243 | 2016-03-23 | 12:05:00 | | 2 | 1 | 9574 | 2016-03-23 | 12:15:00 | | 1 | 1 | 2174 | 2016-03-27 | 12:05:00 | | 1 | 2 | 5474 | 2016-03-24 | 14:05:00 | | 2 | 2 | 8763 | 2016-03-24 | 14:15:00 | | 1 | 2 | 5674 | 2016-03-28 | 14:05:00 | +----------------+-----------+------------+------------+----------+ If I now insert a new appointment for doctor #1 on the 23rd, the new record is created with id=3 INSERT INTO appointment (doctor_id, patient_id, app_date, app_time) VALUES (1, 9991, '2016-03-23', '15:00'); +----------------+-----------+------------+------------+----------+ | appointment_id | doctor_id | patient_id | app_date | app_time | +----------------+-----------+------------+------------+----------+ | 1 | 1 | 3243 | 2016-03-23 | 12:05:00 | | 2 | 1 | 9574 | 2016-03-23 | 12:15:00 | | 1 | 1 | 2174 | 2016-03-27 | 12:05:00 | | 1 | 2 | 5474 | 2016-03-24 | 14:05:00 | | 2 | 2 | 8763 | 2016-03-24 | 14:15:00 | | 1 | 2 | 5674 | 2016-03-28 | 14:05:00 | | 3 | 1 | 9991 | 2016-03-23 | 15:00:00 | <--- new +----------------+-----------+------------+------------+----------+ Now all that is needed is to assemble your code- 8 replies
-
- php
- javascript
-
(and 1 more)
Tagged with:
-
There are no more "will be"s with version 7. It's here now.
-
How can I generate a unique Doctor Appointment ID
Barand replied to sohailsaif's topic in PHP Coding Help
Normalize your data. You have info in both those those tables that doesn't belong. You should have +----------------+ +---------------------+ +-----------------+ | doctor | | appointment | | patient | +----------------+ +---------------------+ +-----------------+ | doctor_id (PK) |---+ | appointment_id (PK) | +---| patient_id (PK) | | doctorname | +----<| doctor_id (FK) | | | patientname | +----------------+ | patient_id (FK) |>---+ | address | | app_time | | mobile | +---------------------+ +-----------------+ If you want doctors with appointment dates, use a query SELECT DISTINCT d.doctor_id , doctorname , DATE(app_time) as Appointment_dates FROM appointment a INNER JOIN doctor d USING (doctor_id); +-----------+------------+-------------------+ | doctor_id | doctorname | Appointment_dates | +-----------+------------+-------------------+ | 1 | Dr A | 2016-03-23 | | 1 | Dr A | 2016-03-27 | | 2 | Dr B | 2016-03-24 | | 2 | Dr B | 2016-03-28 | +-----------+------------+-------------------+ Store dates and time using sql DATETIME types. Other formats cannot be be compared and sorted. eg mysql> SELECT * FROM appointment; +----------------+-----------+------------+---------------------+ | appointment_id | doctor_id | patient_id | app_time | +----------------+-----------+------------+---------------------+ | 1 | 1 | 3243 | 2016-03-23 12:05:00 | | 2 | 1 | 9574 | 2016-03-23 12:15:00 | | 3 | 1 | 2174 | 2016-03-27 12:05:00 | | 4 | 2 | 5474 | 2016-03-24 14:05:00 | | 5 | 2 | 8763 | 2016-03-24 14:15:00 | | 6 | 2 | 5674 | 2016-03-28 14:05:00 | +----------------+-----------+------------+---------------------+ Also, you should not store derived data and your "appointment code" is derived from data already stored and by counting the appointments each day for each doctor. Having got the required data by query you would format it as shown by requinix. Example $sql = "SELECT DATE_FORMAT(app_time, '%d-%m-%Y') as formatteddate , TIME_FORMAT(app_time, '%l:%i %p') as time , @seq := IF(@prevday=DATE(app_time) AND @prevdoc=doctor_id, @seq+1, 1) as seq , @prevdoc:=doctor_id as doctor_id , @prevday:=DATE(app_time) as date FROM ( SELECT doctor_id , app_time FROM appointment JOIN (SELECT @sequence:=0, @prevdoc:=0, @prevday:='1901-01-01') as init ORDER BY doctor_id, app_time ) apps"; $res = $pdo->query($sql); echo "<pre>\n"; echo "Doctor_id Date Seq Code\n"; foreach ($res as $row) { printf(" %d %-15s %3d DR%03d-%s-%04d\n" , $row['doctor_id'] , $row['date'] , $row['seq'] , $row['doctor_id'] , $row['formatteddate'] , $row['seq'] ); } echo "</pre>\n"; Results: Doctor_id Date Seq Code 1 2016-03-23 1 DR001-23-03-2016-0001 1 2016-03-23 2 DR001-23-03-2016-0002 1 2016-03-27 1 DR001-27-03-2016-0001 2 2016-03-24 1 DR002-24-03-2016-0001 2 2016-03-24 2 DR002-24-03-2016-0002 2 2016-03-28 1 DR002-28-03-2016-0001- 8 replies
-
- php
- javascript
-
(and 1 more)
Tagged with:
-
Group By Year, Name, and Count from Two Fields on Same Row
Barand replied to akphidelt2007's topic in MySQL Help
You need to use a UNION SELECT Year , Team , COUNT(*) as Played FROM ( SELECT Year, Away_Team as Team FROM table UNION SELECT Year, Home_Team as Team FROM table ) teams GROUP BY Year, Team -
This may seem an outrageous suggestion but one could always preview and check for typos before hitting the button
-
You could try proximity searches SELECT a.hotelname as hotela , b.hotelname as hotelb FROM hotel a JOIN hotel b ON a.hotel_id <> b.hotel_id AND ABS(a.latitude-b.latitude) < 0.0001 AND ABS(a.longitude-b.longitude) < 0.0001
-
Are donations to specific users okay?
Barand replied to Monkuar's topic in PHPFreaks.com Website Feedback
Still waiting -
If user_id is indexed I suspect it makes very little difference. OTOH, if it isn't indexed and the whole table would require scanning, then there may be an advantage in the LIMIT 1 depending on the target record's position in the table.
-
how to fetch images from images table and display along with topic?
Barand replied to lovephp's topic in MySQL Help
SELECT topic_name , image_name FROM topic t LEFT JOIN image i ON i.tid = t.id I used LEFT join in case some topics have no image. If all topics have an image, use INNER JOIN, it's more efficient. -
Yes. It really means "The MySQL extension is deprecated and has been removed: use mysqli or PDO instead."
-
You should not store data in databases as spreadsheets. You should normalize the data and use the database correctly. So, instead of table1 +--------+------------+-------+-------+-- --+-------+ | recid | other data | MON1 | MON2 | ... | MON50 | +--------+------------+-------+-------+-- --+-------+ | 123 | XYZ1234 | aaa | bbb | ... | ccc | +--------+------------+-------+-------+-- --+-------+ you should have table1 +--------+------------+ | recid | other data | +--------+------------+ | 123 | XYZ1234 | +--------+------------+ | +--------------------------------+ | | table2 +------+--------+------------+--------+ | id | recid | date | value | +------+--------+------------+--------+ | 1 | 123 | 2016-01-01 | aaa | | 2 | 123 | 2016-01-02 | bbb | | 3 | 123 | ... | ... | | 4 | 123 | 2016-01-03 | ccc | +------+--------+------------+--------+
-
You may want to look at string comparison functions such as soundex() levenshtein() metaphone()
-
Why have you defined :idteacher as type PARAM_STR? As soon as you update a record you call return, which immediately exits the function. You should return at the end when all updates have been done
-
Bind the params once before the loop $stmt = $this->db->prepare("UPDATE `esmaior_ca`.`professor` SET `teacher_grupo` = :teacher_grupo WHERE `idteacher` = :idteacher"); $stmt->bindParam(':teacher_grupo', $mudaGrupo, PDO::PARAM_INT); $stmt->bindParam(':idteacher', $id, PDO::PARAM_STR); $myArray = explode(',', $idDocentes); foreach($myArray as $id){ if (!$stmt->execute()) { print_r($stmt->errorInfo()); return array('status' => 'error', 'message' => 'Opppss...no updates..'); } else { return array('status' => 'success', 'message' => 'All changes updated...'); } }
-
That is what I thought. You are are assigning the ids to the $mudaGrupo variable and 0, 1, 2... to the ids. Instead of foreach ($myArray as $id=> $mudaGrupo) you need foreach ($myArray as $id) {
-
You have function to which you pass a comma-delimited list (in $idDocentes) and another value in $mudaGrupo. Without showing any code, tell me what the function is supposed to do with those inputs?
-
Not able to export more than ~50K records
Barand replied to natasha_sharma's topic in PHP Coding Help
The intermediate array is unnecessary. $head = array("ticker", "date_dt", "open", "high", "low", "close", "wap", "os_shares", "ttq", "total_trades", "del_qty", "sales", "profit", "op_assets"); $sql = mysql_query($query); if (mysql_num_rows($sql) > 0) { $file = fopen("stock_history.csv", "w"); fputcsv($file, $head); // write header while ($list = mysql_fetch_row($sql)) { fputcsv($file, $list); // write data } fclose($file); } -
You should NOT be storing them with comma separators, you should be storing them as numeric types. If there are no decimals, you could use INT, Commas and any other formatting should be added on output.
-
You need to use the DATEDIFF() function http://dev.mysql.com/doc/refman/5.6/en/date-and-time-functions.html#function_datediff but the best way to do it is not to do it at all. Derived data should not be stored in your database. Calculate it when required instead of continually updating the table.
-
Pivot Table or Cross Tab in PHP using MYSQL for attendance
Barand replied to akshayhomkar's topic in PHP Coding Help
That earlier post was an example. Here's another http://forums.phpfreaks.com/topic/262473-pivot-table-like-output-indefinite-rows-and-columns-from-flat-data/?do=findComment&comment=1345109 Or do you mean an example which uses your data so that I write your code for you?