Hi,

I will be attempting to learn PHP very shortly.

I am going to create a MySQL database to hold records of students, especially attendance. I would like to know if it is possible to do the following with PHP....

  1. Connect the database with PHP
  2. Add new details to the database while showing and/or keeping previous records
  3. Modify the database e.g. update, remove, change details
  4. Create access permissions for different user groups

I know I have more questions to ask, but cannot think of them just yet.

If someone could provide some insight into the above questions and/or general advice, it would be appreciated.

Thanks.

1. very easy (mysql_connect)
2. believe you are looking for an insert statement
3. update, delete, and update statements
4. schema/user privileges

No1 - Sure
No2 - Clarify what do you have in mind. Mysql allows that one user reads database details, while in the same time another user updates or inserts new records. This is completely doable, but has nothing to do with PHP, more likely, it has to do with mysql.
No3 - also needs clarification - what do you mean by modifying the database - the table structure, or the data contained in the database. Both are doable by php, but these are also mainly capabilities of mysql. In general, if you send the correct command to mysql, either from php, any other graphical or user interface( e.g. command line), mysql will do whatever you want it to do - modify records, modify table structure, etc...
No4 - there are several options for creating a user administration. Normally - I suppose you wold like your users to login and then be able to view only this information that is available for the kind of login they make. This is doable either by mysql user definition, or by creating your own rules for control who has access and where has access...

Thanks for the replies so far.

I forgot to mention that I will create a log-in so only authorized users have access.

Rhyan, I'll do my best to answer your questions..

No2 - Clarify what do you have in mind. Mysql allows that one user reads database details, while in the same time another user updates or inserts new records. This is completely doable, but has nothing to do with PHP, more likely, it has to do with mysql.

Maybe this example diagram would help

[IMG]http://img515.imageshack.us/img515/7769/image1my3.jpg[/IMG]

1. As you can see the Week 1 register has been taken and we're now on Week 2; however, I'd want the register to still show the attendance for Week 1 as well as all future weeks (Week 3, 4, 5 etc) even if they are empty.
2. Student 4's attendance has not been completed (for whatever reason), so I'd like to go back and correct it at any point.
3. Also, I'd like to add a new student at any stage, if needed, without losing current data.

Does that make sense? I want to keep things simple and not over complicate them.

No3 - also needs clarification - what do you mean by modifying the database - the table structure, or the data contained in the database. Both are doable by php, but these are also mainly capabilities of mysql. In general, if you send the correct command to mysql, either from php, any other graphical or user interface( e.g. command line), mysql will do whatever you want it to do - modify records, modify table structure, etc...

Here I mean to modify the data contained in the database i.e. edit/update details, delete students etc.

Here's another example diagram...

[IMG]http://img61.imageshack.us/img61/8574/image2ih7.jpg[/IMG]
Note: "Register" is meant to be for attendance.

What I had in mind is that the user clicks on a button and then is able to do the required action. Maybe have a mini Admin panel that could accomplish the tasks.

No4 - there are several options for creating a user administration. Normally - I suppose you wold like your users to login and then be able to view only this information that is available for the kind of login they make. This is doable either by mysql user definition, or by creating your own rules for control who has access and where has access...

Yes, that is correct. I want different user groups to have certain privileges.

I hope this is clear. You're advice and ideas are much apperciated.

So, issue no 2 - it is completely clear. Simpliest way is to have one table and as many columns as many weeks you need - normally a complete year of 12 months is 52 weeks, so in this case - 52 columns.
Then you have x number of students wich means x number of rows. Once you have your students entered, you need to update scores for their next week. So No 2 completely doable. There is a better way, but is more complex, so I won't tell you about it.
No.3 - In fact no3 does not differ much from no2. There are some more actions to be taken, but basically it is still update and add or delete records. So it is OK as well...
No4 - well..., in my opinion, user administration is some kind of a science itself, so your simpliest solution is to redirect users to different pages, which have different buttons like edit, add, etc., according to type of login. This is doable by php as well.

Thank you for your advice so far, Rhyan.

I have one more question, if you don't mind. I mentioned earlier...

What I had in mind is that the user clicks on a button and then is able to do the required action...

Could you explain how I would get this to work? For example, if I want to delete a student, I click on Delete Student button/link...then where would this take me? How would I make sure I get to the right area to do this task?

This article has been dead for over six months. Start a new discussion instead.