Jump to content

php sql calendar add events


tom7890

Recommended Posts

I would do as Cronix suggested. Look at all the outputs that you need to produce, as that will dictate what data you need to store. You then need to organize that data into correctly normalized tables. Look at the processes you need to produce those outputs and ensure that your data model will support those processes - by using the relational links in your model can you access the data required for the process to produce working, efficient queries? Remember that as soon as you decide you need a table of staff availabilty, say, then you need a process to maintain that table. Consider what could go wrong. Throw a few "what ifs" at the model.

 

For example, if a doctor goes sick suddenly can the appointments be reallocated easily and patients/staff notified? What would happen if they decided to open on Saturday mornings, would they have to hold off that decision while someone took a few weeks to rewrite the system?

 

When you are happy, start coding. In other words, before you set off on a journey, have a map.

Link to comment
Share on other sites

  • Replies 131
  • Created
  • Last Reply

Top Posters In This Topic

I have listened to your suggestions and have come up with a whole map of what the system needs to do, i am a learning and  this is just a overview and not a proper language modified diagram. 
If i have missed anything i would appreciate if you could let me know or if i have any error, i need to finish this work asap, ive been doing bits by bits but ive just been going round in circles, trying to one thing and then add another etc.. I totally agree with both cornix and barand, it makes more sense to have it laid out and i appreciate your advice and help. 
 
Please see the attached map below

 

 

post-174245-0-44729100-1422058695_thumb.png

Edited by tom7890
Link to comment
Share on other sites

You should store an item of in formation, like names, in one place only. The only things that should be duplicated are id keys.

 

I have added a duty_roster table which would hold

  • staff_id
  • date
  • day start time
  • day end time

to assist in generating the table there is also a holiday table (to show non-available) and, for each staff, a sched_hours table (their normal working week pattern day of week, day start time, day end time).

 

If you limit bookings to, say, a month in advance then the roster table will need to be generated each month in advance. You would also need a facility to edit this table for changes at short notice (which could generate cancellations so the patients will need to be notified)

 

The roster table would define which days, staff and timeslots are available when making bookings.

 

I added a "medical" flag to stafftype table to show which staff would see patients.

An admin flag on the staff file shows who has admin access.

post-3105-0-51430800-1422109055_thumb.png

tom7890.html

Link to comment
Share on other sites

You should store an item of in formation, like names, in one place only. The only things that should be duplicated are id keys.

 

I have added a duty_roster table which would hold

  • staff_id
  • date
  • day start time
  • day end time

to assist in generating the table there is also a holiday table (to show non-available) and, for each staff, a sched_hours table (their normal working week pattern day of week, day start time, day end time).

 

If you limit bookings to, say, a month in advance then the roster table will need to be generated each month in advance. You would also need a facility to edit this table for changes at short notice (which could generate cancellations so the patients will need to be notified)

 

The roster table would define which days, staff and timeslots are available when making bookings.

 

I added a "medical" flag to stafftype table to show which staff would see patients.

An admin flag on the staff file shows who has admin access.

 

i cant get the html file to open. its not working at all. 

Link to comment
Share on other sites

is this correct for add??

 

i have been been using mysql not sqli so want sure

<?php

$db = new mysqli('localhost','root','','booking');

$db->query($sql);

if(isset($_POST['submit']))
{
$rosterid=mysql_real_escape_string($_POST['rosterid']);
$staffid=mysql_real_escape_string($_POST['staffid']);
$date=mysql_real_escape_string($_POST['date']);
$starttime=mysql_real_escape_string($_POST['starttime']);
$endtime=mysql_real_escape_string($_POST['endtime']);


$sql = "INSERT INTO dutyroster(rosterid, staffid, date, starttime, endtime) VALUES (?,?,?,?,?)";

$smt = $db->prepare($sql);
$smt->bind_param('sssss', $rosterid, $staffid, 
$date, $starttime, $endtime);

}
?>
Edited by tom7890
Link to comment
Share on other sites

No. You do NOT want to use mysqli_real_escape_string() WITH bound query parameters as they automatically get escaped in the binding. By manually doing it, it's being escaped 2x which can add unwanted things to your db.

 

Also what's this doing?

$db->query($sql);

 

You don't have $sql at the point when you perform that query. Doesn't look like you want that line at all.

Link to comment
Share on other sites



<?php

$db = new mysqli('localhost','root','','booking');


$stmt = $mysqli->prepare("INSERT INTO roster(rosterid, staffid, date, starttime, endtime) VALUES (?,?,?,?,?)");

$stmt->bind_param('iisss', $rosterid, $staffid, 
$date, $starttime, $endtime);
$stmt->execute();
$stmt->close();

?>

Now is this correct? 

Edited by tom7890
Link to comment
Share on other sites

<?php
$db = new mysqli('localhost','root','','booking');

$sql = "INSERT INTO roster('rosterid', 'staffid', 'date', 'starttime', 'endtime') VALUES (?,?,?,?,?)";

$stmt = $db->prepare($sql);

$stmt->bind_param("iisss", $rosterid, $staffid, 
$date, $starttime, $endtime);
$stmt->execute();
$stmt->close();
?>

<?php


$sql = "UPDATE roster(rosterid, staffid, date, starttime, endtime) VALUES (?,?,?,?,?)";

$stmt = $db->prepare($sql);

$stmt->bind_param('iisss', '$rosterid', '$staffid', 
'$date', '$starttime', '$endtime');
$stmt->execute();
$stmt->close();
?>

<?php
$sql = "DELETE  FROM roster(rosterid, staffid, date, starttime, endtime) VALUES (?,?,?,?,?)";

$stmt = $db->prepare($sql);

$stmt->bind_param('iisss', '$rosterid', '$staffid', 
'$date', '$starttime', '$endtime');
$stmt->execute();
$stmt->close();
?>

i have updated the code, is this correct? 

 

 

Edited by tom7890
Link to comment
Share on other sites

I really don't understand what you are doing.

 

You are doing an insert, followed by an update, followed by a delete statement. Whats the purpose?

 

You are inserting/updating data, which doesn't seem to exist. Where are your $rosterid, $staffid, $date, $starttime, $endtime variables coming from that you are inserting/updating?

 

Also, when updating or deleting, you usually have a WHERE clause, or else it might update/delete ALL rows in your table.

 

DELETE from table WHERE field = some_value;

 

UPDATE table SET field1 = value1, field2 = value2 WHERE field = some_value;

 

Where I am saying "field = some_value"..."field" is usually an ID field, and "some_value" is the actual ID

Edited by CroNiX
Link to comment
Share on other sites

It would probably be helpful for you to create 3 individual files, create.php, edit.php and delete.php and put the relevant code in each.

Each file would contain the code necessary to perform the indicated function, including displaying the form, submitting the form, processing the form data, and the appropriate database action. You need to be able to actually test this stuff and if all code is in a single file, you can't easily do that, at least the way you are doing it.

Link to comment
Share on other sites

And you are trying to use the same statement syntax for update and delete that you used for insert. They all use different statements syntaxes. :rtfm:

 

http://dev.mysql.com/doc/refman/5.6/en/insert.html

http://dev.mysql.com/doc/refman/5.6/en/update.html

http://dev.mysql.com/doc/refman/5.6/en/delete.html

Link to comment
Share on other sites

And you are trying to use the same statement syntax for update and delete that you used for insert. They all use different statements syntaxes. :rtfm:

 

http://dev.mysql.com/doc/refman/5.6/en/insert.html

http://dev.mysql.com/doc/refman/5.6/en/update.html

http://dev.mysql.com/doc/refman/5.6/en/delete.html

 

i know they are seperate syntaxe statements, ive just got into a pickle because of using sqli. :s

Edited by tom7890
Link to comment
Share on other sites

create the code to maintain (add, edit, delete) the tables then you can use those to create the test data to use when coding and testing the main processes (booking and reporting)


 

Barand what did u mean? im a little confused as what will i be editing or deleting?

 

i know its the appointments but im confused

Edited by tom7890
Link to comment
Share on other sites

What are you going to do if someone needs to change their appointment? Edit.

What are you going to do if someone cancels an appointment? Delete.

yea i understand that, but in the code when u write 

 

delete from where ?? 

 

?? is this the id? 

 

i mean would it be like so 

 

$sql = "DELETE FROM (roster_id, staff_id, date, start_time, end_time) WHERE id=1";

 

what if the roster_id is 4? can i leave the 1 blank like so id=?;

Edited by tom7890
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.