Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/ubik69/backEndDevelopment/llms.txt

Use this file to discover all available pages before exploring further.

Overview

The Primary School Management System provides dedicated view pages for browsing all records in the database. Each view page displays data in a tabular format, retrieved directly from the MySQL database using PHP.

Accessing View Pages

1

Open the View menu

Click on the View dropdown button in the navigation bar at the top of any page.
2

Select record type

Choose which type of records you want to view:
  • Student
  • Parent
  • Teacher
  • Class
  • Contact
  • Gym Member
  • Salary
3

Browse the data

The selected view page displays all records in a table format.
All view pages are PHP files that execute database queries when loaded and dynamically generate HTML tables with the results.

Viewing Students

The student view page (ViewStudent.php) displays all student records from the Student1 table.

Student Table Columns

The student table displays the following columns:
ColumnDescription
Student IDAuto-generated unique identifier (Sid)
Student First NameStudent’s first name (Sname)
Student Last NameStudent’s last name (Ssurname)
Student BirthdayDate of birth (Sbirthday)
Student’s Parent IDAssociated parent record (Parent_ID)
Student’s Class IDAssociated class record (Class_ID)

Implementation

The student view page uses this PHP code to fetch and display data:
<?php
$link = mysqli_connect(
    "sdb-57.hosting.stackcp.net", 
    "student84-353031351c89", 
    "ua92-studentAc", 
    "student84-353031351c89"
);

if ($link === false) {
    die("Connection failed: ");
}
?>

<h3>See all Students</h3>
<table>
    <tr>
        <th width="150px">student ID<br><hr></th>
        <th width="250px">Student First Name<br><hr></th>
        <th width="250px">Student Last Name<br><hr></th>
        <th width="120px">Student Birthday<br><hr></th>
        <th width="100px">Student's Parent ID<br><hr></th>
        <th width="100px">Student's Class ID<br><hr></th>
    </tr>
    
    <?php
    $sql = mysqli_query($link, "SELECT Sid,Sname,Ssurname,Sbirthday,Parent_ID,Class_ID FROM Student1");
    while ($row = $sql->fetch_assoc()) {
        echo "
        <tr>
            <th>{$row['Sid']}</th>
            <th>{$row['Sname']}</th>
            <th>{$row['Ssurname']}</th>
            <th>{$row['Sbirthday']}</th>
            <th>{$row['Parent_ID']}</th>
            <th>{$row['Class_ID']}</th>
        </tr>";
    }
    ?>
</table>
The fetch_assoc() function retrieves each result row as an associative array, where field names are case-sensitive and match the database column names.

Example Student View

When you navigate to ViewStudent.php, you’ll see a table like this:
student IDStudent First NameStudent Last NameStudent BirthdayStudent’s Parent IDStudent’s Class ID
1JohnSmith2015-03-1552
2SarahJohnson2014-07-2262
3MichaelBrown2016-01-1071

Viewing Teachers

The teacher view page (ViewTeacher.php) shows all teacher records with detailed information.

Teacher Table Columns

ColumnDescription
Teacher IDUnique identifier (Teacher_ID)
Teacher bonus amountMonetary bonus (bonus_amount)
Teacher Field NameSubject/specialization (teacher_field)
Teacher First NameFirst name (Tname)
Teacher Last NameLast name (Tsurname)
Teacher AddressResidential address (Taddress)
Teacher MobilePhone number (Tmobile)
Teacher EmailEmail address (Temail)

SQL Query

The teacher view executes this query:
$sql = mysqli_query($link, 
    "SELECT Teacher_ID,bonus_amount,teacher_field,Tname,Tsurname,Taddress,Tmobile,Temail FROM Teacher"
);

while ($row = $sql->fetch_assoc()) {
    echo "
    <tr>
        <th>{$row['Teacher_ID']}</th>
        <th>{$row['bonus_amount']}</th>
        <th>{$row['teacher_field']}</th>
        <th>{$row['Tname']}</th>
        <th>{$row['Tsurname']}</th>
        <th>{$row['Taddress']}</th>
        <th>{$row['Tmobile']}</th>
        <th>{$row['Temail']}</th>
    </tr>";
}
Teacher records include comprehensive contact information, making it easy to reach staff members when needed.

Example Teacher View

Teacher IDBonus AmountFieldFirst NameLast NameAddressMobileEmail
1500.00MathematicsJaneDoe123 Main St555-0101jane.doe@school.com
2750.00ScienceRobertWilson456 Oak Ave555-0102r.wilson@school.com

Viewing Parents

The parent view page (ViewParent.php) displays all parent/guardian records in the system.

Parent Information

Parent records typically include:
  • Parent ID
  • Parent First Name (Pname)
  • Parent Last Name (Psurname)
  • Parent Address (Paddress)
  • Parent Email (Pemail)
Parent records are linked to student records via the Parent_ID foreign key in the Student table.

Viewing Classes

The class view page (ViewClass.php) shows all class configurations.

Class Information

Class records display:
  • Class ID
  • Class Name/Year (classYear)
  • Class Capacity (capacity)
  • Assigned Teacher ID (Teacher_ID)
You can use this view to see which teachers are assigned to which classes and monitor class capacity.

Viewing Contacts

The contacts view page (ViewContact.php) displays all contact form submissions or contact information.

Viewing Gym Members

The gym member view page (ViewGymMember.php) shows students or staff enrolled in gym programs.

Viewing Salaries

The salary view page (ViewSalary.php) displays salary information for teachers.

Salary Information

Salary records typically include:
  • Teacher ID
  • Salary Amount
  • Working Type (Part-Time or Full-Time)
Salary information is sensitive data. Ensure only authorized personnel have access to the salary view pages.

How View Pages Work

1

Database connection established

When you access a view page, PHP first establishes a connection to the MySQL database:
$link = mysqli_connect(
    "sdb-57.hosting.stackcp.net", 
    "student84-353031351c89", 
    "ua92-studentAc", 
    "student84-353031351c89"
);
2

SQL query executed

The page executes a SELECT query to fetch all records from the relevant table:
$sql = mysqli_query($link, "SELECT * FROM TableName");
3

Results retrieved as associative array

Each row is fetched using fetch_assoc(), which returns an associative array:
while ($row = $sql->fetch_assoc()) {
    // Access fields using $row['fieldname']
}
4

HTML table dynamically generated

The PHP code generates HTML table rows for each database record:
echo "<tr>
    <th>{$row['field1']}</th>
    <th>{$row['field2']}</th>
</tr>";

Table Formatting

All view tables use HTML with CSS styling:
<table>
    <tr>
        <th width="150px">Column Header<br><hr></th>
        <th width="250px">Another Header<br><hr></th>
    </tr>
    <!-- Data rows inserted here -->
</table>
Column widths are specified in pixels to ensure consistent layout. Each header includes a horizontal rule (<hr>) for visual separation.
All view pages include the same navigation bar, allowing you to quickly switch between different record types without returning to the home page.
The navigation bar is consistent across all pages, making it easy to navigate between Add, View, Delete, and Update operations for any record type.

Troubleshooting

If a view page doesn’t display data:
1

Check database connection

Verify the MySQL connection is established successfully. If connection fails, you’ll see “Connection failed:” message.
2

Verify table has data

The table might be empty if no records have been added yet. Use the Add menu to create sample records.
3

Check table and column names

Ensure the SQL query references the correct table and column names (case-sensitive).
4

Review PHP errors

Enable error reporting to see any PHP errors that might prevent data from displaying.
View pages display all records without pagination. Large datasets may cause slow page loads or browser performance issues.