Select query in php

From the select query in php we are going to select entire or extract data from the table. We are using mysql_query() to retrieve the data. Here example for goes to get data from database.


<?php
          $conn=mysql_connect("localhost","root","");
          $sel=mysql_select_db("proj",$conn);
          $c = mysql_query("select * from data");
          echo "<table border='1'>";
          echo "<tr><td>name</td><td>Last name</td><td>Address</td><td>Email id</td><td>Phone</td></tr>";
          while($row = mysql_fetch_array($c))
          {
                   echo "<tr><td>$row[0]</td><td>$row[1]</td><td>$row[2]</td><td>$row[3]</td><td>$row[4]</td></tr>";
          }
          echo "</table>";
?>

Output:



Post a Comment