Sharp Tutorial
select in php using mysql

Python

Java

C

C++

HTML/CSS

Java Script

PHP

SQL

C Programs

PHP Introduction

  • PHP home
  • PHP introduction
  • How to install and run
  • Syntax and Rule in PHP
  • Data type and operator
  • If else in php
  • Loop in php
  • Array in php
  • Sring in php
  • Function in php
  • Include in php

Working with Forms

  • Get and Post
  • Get Form input into PHP
  • Form Validation

PHP with MySQl

  • Connect PHP & Mysql
  • Insert using PHP Mysql
  • Select using PHP MySql
  • Delete Update using PHP Mysql
  • Login Page Example in PHP

Advanced PHP

  • Session in PHP
  • Cookies in PHP
  • File Handling in PHP
  • File Upload/Download PH

Object Oriented PHP

  • Class Obejct in PHP
  • Constructor in PHP
  • Destructor in PHP
  • Inheritance in PHP

select from mysql using php

Using PHP we can fetch data from database by firing select query. To display the selected data we will use html table here, the database connection will be created like as before examples.

PHP page to get data from database and display in html table

 <html>
<body bgcolor="gray">
<center>
<table style="width:80%; background-color:yellow;" border="5">
<th>Roll No</th>
<th>Name</th>
<th>Course</th>
<?php
  $host="localhost";
$dbuser = "root";
$password = ""; // change password as per your database.
$dbname= "sharp_tutorial";
$conn = mysqli_connect($host, $dbuser, $password,$dbname);
$query=" select * from student ";
$data=mysqli_query($conn,$query);
if(mysqli_num_rows($data) > 0) {
while($row= mysqli_fetch_assoc($data)) {
echo"<tr>";
echo "<td>". $row['rollNo']. "</td>";
echo "<td>". $row['sname']. "</td>";
echo "<td>". $row['course']. "</td>";
echo"</tr>";
}
}
?>
</table>
<center></body>
</html>

Above program Displays the all records from student table as following to filter the records where clause can be used.

Enquiry about Course

Ask your Question

Click Here

Sharp (2) Tutorials

Video/ C Introduction

Watch video in full size

Video tutorial

Follow by Email
Facebook
Facebook
fb-share-icon
YouTube
Copyright © Sharp Tutorial
Build with WordPress
Wordpress Social Share Plugin powered by Ultimatelysocial
Sharp Tutorial