X

Learn How to Become a Web Developer With PHP-Part 2-Student Records

Learn How to Become a Web Developer With PHP-Part 2, In previous post we learned basic concept about web development with php. In this post i’m going to write about Web development with PHP on real example – Student  Records. In this application you will learn

  • Adding new Student Record
  • Display All student Record

Learn Basic Web development : –

Learn How to Become a Web Developer With PHP

Create Database and Tables

Create Database Name student in phpmyadmin . Very easy for beginner to create database and table.

Create Database

Create Table

Create Dashboard

In dashboard Page, we have Add student and Display all student record menu that navigate to particular functionality, so lets start the coding Part.

Index.php

index.php is main panel for our application where user can choose what they want.

<!DOCTYPE html>
<html>
<head>
<title>Student Record | techjunkgigs </title>
<meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<h1 class = "jumbotron text-center"><b><u><a href = "index.php">Student Record</a></u></b></h1>
<div class="container-fluid well">
    <ul class="nav navbar-nav">
      <li><a href="add.php">Add New Student Record</a></li>
      <li><a href="display.php">Display Student Record</a></li>
    </ul>
  </div>
</body>
</html>

Image for Student record main panel

add.php

add.php file contain all the text box which require to get the student details.

<?php
$con = mysqli_connect("localhost","root","","student");
if(isset($_POST['submit']))	
{
	$name = $_POST['name'];
	$dob = $_POST['dob'];
	$class = $_POST['class'];
	$doj = $_POST['doj'];
	mysqli_query($con,"insert into tbl_student (name,dob,class,doj) values ('$name','$dob','$class','$doj')");
	echo "<b>Added successfully</b>";
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Student Record | techjunkgigs </title>
<meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<h1 class = "jumbotron text-center"><b><u><a href = "index.php">Student Record</a></u></b></h1>
<div class="container-fluid well">
    <ul class="nav navbar-nav">
      <li class = "active"><a href="add.php">Add New Student Record</a></li>
      <li><a href="display.php">Display Student Record</a></li>
    </ul>
  </div>
  <div class="container-fluid">
   <form method = "POST">
	<div class="row">
    <div class="col-sm-4">
	<label for="Name">Student Name</label>
      <input type="text" class="form-control" name="name">
	</div>
    <div class="col-sm-4">
	<label for="DOB">Date Of Birth</label>
      <input type="date" class="form-control" name="dob">
	</div>
	<div class="col-sm-4">
	<label for="Class">Class</label>
      <input type="class" class="form-control" name="class">
	</div>
	<div class="col-sm-4">
	<label for="DOJ">Date of Joining</label>
      <input type="date" class="form-control" name="doj">
	</div>
    </div><br/>
	<div class = "row">
	<div class="col-sm-2">
      <input type="submit" class="form-control" name = "submit" value = "Submit">
	</div>
	</div>
  </form>
  </div>
</body>
</html>

Image for Add Student Panel

display.php

Display all student record in table from MySQL Database with display.php file.

<?php
$con = mysqli_connect("localhost","root","","student");
if(isset($_POST['submit']))	
{
	$name = $_POST['name'];
	$dob = $_POST['dob'];
	$class = $_POST['class'];
	$doj = $_POST['doj'];
	mysqli_query($con,"insert into tbl_student (name,dob,class,doj) values ('$name','$dob','$class','$doj')");
	echo "<b>Added successfully</b>";
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Student Record | techjunkgigs </title>
<meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<h1 class = "jumbotron text-center"><b><u><a href = "index.php">Student Record</a></u></b></h1>
<div class="container-fluid well">
    <ul class="nav navbar-nav">
      <li class = "active"><a href="add.php">Add New Student Record</a></li>
      <li><a href="display.php">Display Student Record</a></li>
    </ul>
  </div>
  <div class="container-fluid">
   <table class = "table">
		<thead>
      <tr>
        <th>Student Name</th>
        <th>Date Of Birth</th>
        <th>Class</th>
        <th>Date Of Joining</th>
      </tr>
    </thead>
	
	<?php
	$con = mysqli_connect("localhost","root","","student");
	$sql = "select * from tbl_student";
	$result= mysqli_query($con,$sql);
	while($row = mysqli_fetch_array($result))
	{
	?>
	<tr>
        <td><?php echo $row['name']; ?></td>
        <td><?php echo $row['dob']; ?></td>
        <td><?php echo $row['class']; ?></td>
        <td><?php echo $row['doj']; ?></td>
	</tr>
	<?php } ?>
   </table>
  </div>
</body>
</html>

Image for Display Student Panel

Download the Project File from Here

[sociallocker]Student Record[/sociallocker]

Note : – Knowing and developing the application is your greatest skill and capability but for landing a good job, you have to prepare for interview. So here Toptal is providing the Key PHP Concepts and Paradigms. Go and check out, it help you a lot.

I hope this tutorial helped you to learn how to create PHP application with MySQL. To get the latest news and updates follow us on twitter facebook, subscribe to our YouTube channel.  And If you have any query then please let us know by using comment form.

Categories: CSS HTML MySQL PHP
Jamaley Hussain: Hello, I am Jamaley. I graduated from Staffordshire University and have always been passionate about Computers, Technology, and Generative AI. Currently, I work as a Senior Data Scientist (AI/ML) and I’m also the founder of TechJunkGigs, a platform dedicated to helping programming students with tutorials on Machine Learning, Data Science, Python, LLM, RAG, Generative AI, and NLP. What started as a blog has now evolved into a valuable resource for students, and I'm committed to sharing knowledge to help them stay updated with industry trends
Related Post