+----+-----------+------------+
| sn | name | number |
+----+------------------------+
| 1 | Suman | 9842681448 |
| 2 | Sabin | 9807985420 |
| 3 | Sunam | 9815099890 |
+----+-----------+------------+
Here are the required information for the web:
Server name: localhost
Username : ksumanadhikari
Password : welcome
lets create a database named db1 and create a table named tb1 with following command.
create database db1;
use db1;
create table tb1(sn auto_increment primary key, name varchar(50), number bigint);
insert into tb1(name, number) values
("Suman",9842681448),
(" Sabin" ,9807985420),
("Sunam",9815099890);
Now lets Create a Simple HTML for a table .
<html>
<body>
<?php
$conn=mysqli_connect('localhost','ksumanadhikari','welcome','db1') ;
$sql='select * from tb1';
$result=mysqli_query($conn,$sql) or die("Sql Connection Failed.");
if(mysqli_num_row($result)>0){
?>
<table border=1>
<th>
<tr>
<td>S.N</td>
<td>Name</td>
<td>Number</td>
</tr>
</th>
<?php
while($row=mysqli_fetch_assoc($result))
?></tr>
<tr>
<td><?php echo $row['sn']; ?></td>
<td><?php echo $row['name']; ?></td>
<td><?php echo $row['number']; ?></td>
<?php
}
?>
</table>
<?php
}else{
echo "Table NOt found";
mysqli_close($conn);
}
?>
0 comments:
Post a Comment