Вы находитесь на странице: 1из 5

Jomari Laylay

Program Code:

Index.php

<html>

<body>

<style>

table {

font-family: arial, sans - serif;

border-collapse: collapse;

width: 40%;

td, th{

border: 1px solid #dddddd;

text-align: left;

padding: 8px;

tr: nth-child(even){

background-color: #dddddd;

</style>

<h2>Student Details</h2>

<a href="create.php">Add New Student</a>

</body>

</html>
<?PHP

require_once "config.php";

$sql = "SELECT * FROM tblstudents order by LastName";

if($result = mysqli_query($link, $sql)){

if(mysqli_num_rows($result) > 0){

echo "<table>";

echo "<br>";

echo "<tr>";

echo "<th>student ID</th>";

echo "<th>LastName</th>";

echo "<th>FirstName</th>";

echo "<th>MiddleName</th>";

echo "<th>Age</th>";

echo "<th>Course</th>";

echo "<th>Year Level</th>";

echo "<th>email</th>";

echo "<th>mobile Number</th>";

echo "<th>Action</th>";

echo "</tr>";

echo "<br>";

while($row = mysqli_fetch_array($result)){

echo "<tr>";

echo "<td>" . $row['studentID'] . "</td>";

echo "<td>" . $row['LastName'] . "</td>";


echo "<td>" . $row['FirstName'] . "</td>";

echo "<td>" . $row['MiddleName'] . "</td>";

echo "<td>" . $row['Age'] . "</td>";

echo "<td>" . $row['Course'] . "</td>";

echo "<td>" . $row['YearLevel'] . "</td>";

echo "<td>" . $row['email'] . "</td>";

echo "<td>" . $row['mobileNumber'] . "</td>";

echo "<td>";

echo "a href='read.php?studentID=". $row['studentID'] ."'>View


</a>";

echo "a href='update.php?studentID=". $row['studentID'] ."'>Edit


</a>";

echo "a href='delete.php?studentID=". $row['studentID'] ."'>Delete


</a>";

echo "</td>";

echo "</tr>";

echo "<br>";

echo "</table>";

else{

echo "<p>No records found.</p>";

}
else{

echo"ERROR: Could not execute $sql.". mysqli_error($link);

mysqli_close($link);

?>

Program Code:

Create.php

<html>

<body>

<h2>Create Record</h2>

<p>Please fill this form and submit to add student record to the database.</p>

<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>"


methods="post">

<label>StudentID:</label>

<input type ="text" name="txtID"><br>

<label>LastName:</label>

<input type ="text" name"txtlname"><br>

<label>FirstName:</label>

<input type ="text" name"txtfname"><br>

<label>MiddleName:</label>

<input type ="text" name"txtmname"><br>

<label>Age:</label>

<input type ="text" name"txtage"><br>

<label>Course:</label>
<input type ="text" name"txtcourse"><br>

<label>YearLevel:</label>

<input type ="text" name"txtyear"><br>

<label>Email:</label>

<input type ="text" name"txtemail"><br>

<label>MobileNumber:</label>

<input type ="text" name"txtmobile"><br>

<input type ="submit" name"btnsubmit" value="Submit"><br>

<a href="index.php">Cancel</a>

</form>

</body>

</html>

Вам также может понравиться