Professional Documents
Culture Documents
Awad 7 & 8
Awad 7 & 8
Module 7
Task: Develop Add Student Profile Page to store data into the database and develop a
webpage to retrieve the student details based on the Roll Number or any unique ID.
<!DOCTYPE html>
<html lang="en">
<head>
<title>retrieve data from database</title>
</head>
<body>
<form action="" method="GET">
Enter ID<input type="text" name="id" value="<?php if(isset($_GET['id'])){echo $_GET['id'];} ?>" >
<button type="submit">Search</button>
//<input type="submit" value="search">
</form>
<?php
$con = mysqli_connect("localhost","root","","20x51a0562");
if(isset($_GET['id']))
{
$id = $_GET['id'];
$query = "SELECT * FROM student WHERE id='$id' ";
$query_run = mysqli_query($con, $query);
if(mysqli_num_rows($query_run) > 0)
{
foreach($query_run as $row)
{
?>
<label for="">Name</label>
<input type="text" value="<?= $row['Name']; ?>" >
<label for="">Email</label>
<input type="text" value="<?= $row['Email']; ?>" >
<label for="">Address</label>
<input type="text" value="<?= $row['Address']; ?>" >
<?php
}
}
else
{
</body>
</html>