PHP Program to Display data in Tabular Structure

By | December 19, 2015

A simple HTML form with Name, Address Line 1, Address Line 2 and E-mail text fields. On submitting the details, it will store the data in MySQL table by calling a PHP program then we have written a PHP Program to Display data in Tabular Structure. 

 

Program.html

<?xml version=”1.0″ encoding=”ISO-8859-1″?>
<html xmlns=”http://www.w3.org/1999/xhtml”>

<body>
<h3> Program to collect the customer-information </h3>
<form action =”http://localhost/13a.php” method=”get”>
<table border=”0″>
<tr>
<td> Enter Name:</td>
<td> <input type=”text” name=”name”> </td>
</tr>
<tr>
<td> Enter Address Line1: </td>
<td> <input type=”text” name=”address1″></td>
</tr>
<tr>
<td> Enter Address line2: </td>
<td> <input type=”text” name=”address2″> </td>
</tr>
<tr>
<td> Enter Email-id: </td>
<td> <input type=”text” name=”email”> </td>
</tr>
<tr>
<td> </td> </tr>
<tr> </tr>
<tr>
<td> <input type=”submit” value=”Submit”></td>

<td> <input type=”Reset” value=”Reset”></td>
</tr>
</br>
<a href=”program.html”> To search click here </a> </td>
</table>
</form>

</body>

</html>

 

Output:

 

 

 

 

Display.php

<html>
<head><title> PHP and MYSQL </title></head>
<body bgcolor=”aabbcc”>
<?php

$name1=$_REQUEST[“name”];

$address1=$_REQUEST[“address1”];

$address2=$_REQUEST[“address2”];

$email=$_REQUEST[“email”];

$mysql=mysql_connect(“localhost”,”root”) or die(“can’t connect”);

mysql_select_db(“DB_NAME”) or die(“can’t select”);

mysql_query(“insert into address values(‘$name1′,’$address1′,’$address2′,’$email’)”)or die(“query failed to insert”);

$result=mysql_query(“select * from address”);

?>

<h3> Page to display the stored data </h3>

<table border=”1″>
<tr>
<th> NAME </th>
<th> ADDRESS Line1 </th>
<th> ADDRESS Line2 </th>
<th> EMAIL-id </th> </tr>

<?while($array=mysql_fetch_row($result)):?>
<tr>
<td><?echo $array[0];?></td>
<td><?echo $array[1];?></td>
<td><?echo $array[2];?></td>
<td><?echo $array[3];?></td>
</tr>

<?endwhile;?>
<?mysql_free_result($result);?>
<?mysql_close($mysql);?>
</table>
</body>
</html>

 

Output:

PHP Program to Display data in Tabular Structure

PHP Program to Display data in Tabular Structure


 

Please Share: Tweet about this on TwitterShare on FacebookShare on Google+Share on RedditPin on PinterestShare on LinkedInDigg thisShare on StumbleUponShare on TumblrBuffer this pageShare on VKEmail this to someone

Leave a Reply

Your email address will not be published. Required fields are marked *