Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Display data from database in php
12-14-2011, 04:22 PM
Post: #1
Display data from database in php
Today we are going to learn how to display data from database in PHP

First create a database in mysql
create database databasename;
create a table named one or any name
create table one(name varchar(20));
insert into one values('sample1');
insert into one values('sample2');


create a php page to display data from database

Quote:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Display data from database by s2sgateway.com </title>
</head>

<body>

<?php
$host="localhost";
$user="yourmysqlusername";
$pass="yourmysqlpassword";
$se=mysql_connect($host,$user,$pass);
if($se)
{
print_r ("connected");
}
else
{
print_r (mysql_error());
}

$s1=mysql_select_db("dbname",$se);
if($s1)
{
print_r("database working");
}
else
{
echo mysql_error();
}
echo $s1;
$new=mysql_query("select * from one");
while($row = mysql_fetch_array($new))
{
echo "results".$row['name'];
}

?>
</body>
</html>


Any doubt ask us.

Happy coding.
Find all posts by this user
Add Thank You Quote this message in a reply
Post Reply 


Possibly Related Threads...
Thread: Author Replies Views: Last Post
  Hsqldb another database how to use it. mjm 0 196 01-03-2012 04:32 AM
Last Post: mjm
Tongue Finding/removing duplicate values from database using sql rajasri 0 61 12-19-2011 10:17 PM
Last Post: rajasri
Sad Create database and table from jsp page rajasri 0 265 12-13-2011 03:06 AM
Last Post: rajasri
Smile How to backup database of mysql using bat rajasri 0 176 12-13-2011 02:41 AM
Last Post: rajasri
Wink Exception:com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for colu rajasri 0 360 12-13-2011 02:09 AM
Last Post: rajasri

Forum Jump:


User(s) browsing this thread: 1 Guest(s)


WE will share important jobs and updates on facebook so like us to get updates