Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7693657
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T21:08:26+00:00 2026-05-31T21:08:26+00:00

Ok, I couldn’t insert the overview image, but I’m required to create a PHP

  • 0

Ok, I couldn’t insert the overview image, but I’m required to create a PHP app for my studies, it must allow student to register, and the administrator to edit course and student info.
We are not required to code it in an OOP style, but since its the best programming practice to code in OOP, why not learn OOP from the beginning.

I’m a beginner but I know the basics about OOP, classes, inheritance, setters and getters and all that cool lingo, but I’m struggling to decide which parts of this app should be objects, should I make course and student classes or add, edit and delete classes? Any advice on how to approach and visualize such a problem would be appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T21:08:28+00:00Added an answer on May 31, 2026 at 9:08 pm

    Very roughly: This is how I would do it:

    1. Store your data in SQL or XML. You will need two SQL tables, one for Students and one for Courses. You can use one XML file containing all the data, or you can use two files (which I recommend).

    2. Create a class called, for example, dataItem with a property like ‘$arr_fields’ corresponding to a single data record (a single row in a SQL table, or an XML record).

    3. The dataItem class should have the following methods (all public):

      • loadFromSQL() (or loadFromXML())
      • saveToSQL() (or saveToXML())
      • add(), edit() and delete()
      • a view() method using HTML
      • These methods are obviously used to read and write data between the SQL/XML data and $arr_fields of the class, and to display the data in $arr_fields. The keys of $arr_fields are the SQL column names (or XML tag or attribute names) for the specific SQL table.
    4. Try not to call loadFromSQL() or saveToSQL() in your constructor or in any of the other methods which are used to modify only the class data. Keep these actions separate. EDIT: This is a personal preference which helps me to keep track of the state of my objects.

    5. Create Student and Course classes that extends the dataItem class.

    6. You can override methods, for instance the view() method, inside your extended classes if you need to.

    7. Then you can call the methods in Students and Courses from an Admin object (like rcdmk suggested) or maybe from StudentFolder and CourseFolder classes whose view() method contains buttons for the actions that need to be performed. (Let StudentFolder and CourseFolder extend a Folder class that you create).

    UPDATE:

    For example: If your primary key in a SQL table is id, then dataItem’s loadFromSQL($id, $tablename) should set $arr_fields so that its keys are the column names and it’s values are the values from the row whose primary value is equal to $id.

    In Students, you can then override loadFromSQL() as follows:

    class Students extends dataItem {
    
      // other attributes 
    
       public function loadFromSQL($id) {
         parent::loadFromSQL($id, "Students");
       }
    
    }
    

    EDIT: On reconsideration, it might be better to set $arr_fields[“id”] = $id and also set $tablename with the constructor for dataItem – then you never have to override loadFromSQL() or specify parameters for it. loadFromSQL() should then load the record if it exists. saveToSQL() should save $arr_fields in SQL if $arr_fields[“id”] is set and create a new record if it is not set. Anyway, you must find a consistent way of interacting with the data which works for you, these are just possibilities.

    However, if you are not experienced with OOP and SQL or XML, you might be opening a can of worms for yourself and it might be better to just do your assignment using functions only and php arrays for your data. Unless you have some time to learn…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Couldn't find an answer to this question. It must be obvious, but still. I
I couldn't really come up with a proper title for my question but allow
I couldn't really find this in Rails documentation but it seems like 'mattr_accessor' is
I couldn't find a more descriptive title, but here there is an example: import
couldn't find a similar topic but this may boil down to not knowing how
Couldn't think of a more appropriate question title, but I'm looking for some advice
i couldn't find in one place ,all the Appstore rules for the required images
i couldn't send data from my device to my php file. i am trying
I couldn't find any documentation on gitk about what the colors mean, but the
I couldn't find out python equivalent to PHP $_SERVER. Is there any? Or, what

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.