Tuesday, December 24, 2024

Task 2: Create a database named 'age' and table also named 'age' then input some manual data and display it with SN and age.

Lets create a database with given command.

create database age;

use age;

create table age(sn int auto_incerement primary key, age int);
insert into age( age)

values

(1),(5),(6),(5),(85),(56),(56),(5656560);

+----+--------+
| sn | num    |
+----+--------+
|  1 |      1 |
|  2 |      5 |
|  3 |      6 |
|  4 |      5 |
|  5 |     85 |
|  6 |     56 |
|  7 |     56 |
|  8 | 565656 |
+----+--------+

Lets create the HTML for this Query Read .

<html>
<body>
<?php
$conn=mysqli_connect('localhost','ksumanadhikari','welcome','age');
$sql='select * from age';
$result=mysqli_query($conn,$sql);
if(mysqli_num_rows($result)>0){
?>
<table border="3">
<tr>
<th>sn</th>
<th>num</th>
</tr>

<?php while($row=mysqli_fetch_assoc($result)){ ?>
<tr>
<th><?php echo $row['sn']; ?></th>
<th><?php echo $row['num']; ?></th>
</tr>
<?php } ?>
</table>
<?php }else{
echo "table not found";
mysqli_close($conn);
}?>
</body>
</html>

This is the output of this Code :



Database


Web View


0 comments:

Post a Comment

Copyright © Web Devloper LogBook | Powered By Blogger | Blogger Templates
Design by Saeed Salam | Blogger Theme by NewBloggerThemes.com