ID | NAME | percentage |
---|---|---|
1 | ram | 77 |
2 | ramya | 88 |
3 | kusuma | 88 |
Instructions:
1. Create database in mysql using phpmyadmin page in wamp server
2. create student table with student(id,name,percentage, year)
3. use this details in php program
database name : mytestdata
user name : root
password : ***
table name : student
columns : id, name , percentage, year
< style >
table, th, td {
border: 1px solid black;
}
< /style >
< ? php
$servername = "localhost";
$username = "root";
$password = "12345678";
$dbname = "mytestdb";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT * FROM student";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
echo" ID NAME percentage ";
while($row = $result->fetch_assoc()) {
echo " " . $row["id"]. " " . $row["name"]. " " . $row["percentage"]. " ";
}
echo "
";
} else {
echo "0 results";
}
$conn->close();
?>