Sunday 14 May 2017

Example of Retrieve the whole data from database using my sql in php

Dear Student ,

    Please , Follow the Step ....

1. Create a Table in mySql and insert the Data inside it.


2 . create File with dbconnect.php for connect our file to database

<?php$servername = "localhost";
$username = "root";
$password = "";
$DbName="Registration";
// Create connection
$conn = new mysqli($servername, $username, $password,$DbName);// Check connection
if ($conn->connect_error)
{  
  die("Connection failed: " . $conn->connect_error);
?>

 2. Create A file to ViewData.php for show our data from Database


 <?php

 include("dbconnect.php");

?>

</br>

</br>

</br>

<?php



$sql="SELECT Id,Name,userName,Email,Password,Sex,Mobile_No FROM registartionform";


if ($result=mysqli_query($conn,$sql))

  {

   echo "<center>

   <table border='1'>

   <tr>

   <th>ID</th>

   <th>Name</th>

   <th>User Name</th>

   <th>Email Id</th>

   <th>Password</th>

   <th>Sex</th>

   <th>Mobile No</th></tr>";

  // Fetch one and one row

    while ($row=mysqli_fetch_row($result))

    {

     echo "<tr><td>".$row[0]."</td>

<td>".$row[1]."</td>

<td>".$row[2]."</td>

<td>".$row[3]."</td>

<td>".$row[4]."</td>

<td>".$row[5]."</td>

<td>".$row[6]."<td>

<a href='edit.php'>Edit Record</a></td>"."<td>

<a href='delete.php'>Delete Record</a></td>"."</td></tr>";

    }

echo "</table></center>";

  // Free result set

  mysqli_free_result($result);

}


mysqli_close($conn);

?>

</br>

</br>

</br>

<a href="home.php">Back to Home Page</a>



3.Execute your ViewData from any web browser with following link...

localhost:80/Viewdata.php

Output :




No comments:

Post a Comment