Create database using phpMyAdmin. Write a program to read input data, from table and display all these information in tabular form on output screen || DWPD Sem 5 Practical 21
DWPD : Practical 21
<?php
$con=mysql_connect('localhost','root','');
mysql_select_db('student',$con);
?>
<html>
<head>
<title>Display From Database</title>
</head>
<table border="1">
<tr>
<th>ID</th><th>NAME</th><th>DEPARTMENT</th><th>SEMESTER</th><th>GENDER</th>
</tr>
<?php
$sql="SELECT * FROM student";
$query=mysql_query($sql);
while($raw=mysql_fetch_assoc($query))
{
?>
<tr>
<td><?php echo $raw['id'] ?></td>
<td><?php echo $raw['Name'] ?></td>
<td><?php echo $raw['Dept'] ?></td>
<td><?php echo $raw['Sem'] ?></td>
<td><?php echo $raw['Gender'] ?></td>
</tr>
<?php
}
?>
</table>
Output :
Follow these steps to create database, Create table, insert and view data from table using phpMyAdmin
Step 1 : Turn on local server xampp or wamp then Type localhost in url
Step 2 : click on phpmyadmin
Step 3 : type database name and click Create Button
Step 4 : to create table type table name & number of fields then click GO button
Step 5 : Insert fields name with data type and range, set primary key, auto increment to id and click Save button
Step 6 : After table creation click on insert from navigationStep 7 : Insert values and click Go button at bottom
Step 8 : now click on Browse menu to view inserted data
Step 9 : Now you can see the data in table
Comments
Post a Comment