php提取数据库并显示 php获取数据

如何用php获取数据库信息并显示

获取ppq数据库的所有表名的代码:

成都创新互联公司网站建设服务商,为中小企业提供成都网站制作、成都网站建设服务,网站设计,网站改版维护等一站式综合服务型公司,专业打造企业形象网站,让您在众多竞争对手中脱颖而出成都创新互联公司

?php

$server='localhost';

$user='root';

$pass='12345';

$dbname='ppq';

$conn=mysql_connect($server,$user,$pass);

if(!$conn)

die("数据库系统连接失败!");

$result=mysql_list_tables($dbname);

if(!$result)

die("数据库连接失败!");

while($row=mysql_fetch_row($result))

{

echo

$row[0]."

";

}

mysql_free_result($result);

?

mysql_list_tables

(PHP

3,

PHP

4

,

PHP

5)

mysql_list_tables

--

列出

MySQL

数据库中的表

说明

resource

mysql_list_tables

(

string

database

[,

resource

link_identifier])

mysql_list_tables()

接受一个数据库名并返回和

mysql_query()

函数很相似的一个结果指针。用

mysql_fetch_array()或者用mysql_fetch_row()来获得一个数组,数组的第0列就是数组名,当获取不到时

mysql_fetch_array()或者用mysql_fetch_row()返回

FALSE。

php中怎么从数据库中取出数据?怎么显示?最好有详细的代码

$con=mysql_connect('localhost','root','');//数据库信息

mysql_select_db('shop');//数据库名

mysql_query("set names utf8");//设置字符集编码

$sql="select goods_name,goods_number,shop_price from goods";//查询语句

$res=mysql_query($sql);//执行查询

while($row=mysql_fetch_assoc($res)){

$rows[]=$row;//接受结果集

}

//遍历数组

foreach($rows as $key=$v){

echo $v['goods_name']."---".$v['goods_number']."---".$v['shop_price']."br/";

}

php语言~` 怎么把数据库的信息提取出来 显示在页面上?

?php

//显示多少条数据

$db=mysql_connect("localhost","root","xiaowodcaowugook");

//创建数据库连接

$select=mysql_select_db("xmanman",$db);

//选择要操作的数据库

mysql_query("SET NAMES GBK");

//解决中文乱码问题

$total=mysql_num_rows(mysql_query("select id from gaox"));

//查询数据的总数,id是数据库中的一个自动赋值的字段,gaox是数据库表的名字

$info=mysql_query("select * from gaox order by time desc limit $num");

//获取相应页数所需要显示的数据,order by time desc是按最后留言的排前边,gaox是数据库表的名字

$it=mysql_fetch_array($info);

?

php如何查询数据库表中的数据并显示

这个简单啊!

首页做个前台输入姓名和会员卡信息的页面,我做个简单的页面给你看

!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "

html xmlns="

head

meta http-equiv="Content-Type" content="text/html; charset=utf-8" /

title会员查询系统/title

/head

body

form id="form1" name="form1" method="post" action="test.php"

p

label for="name"/label

input type="text" name="name" id="name" /

/p

p

label for="vipid"/label

input type="text" name="vipid" id="vipid" /

/p

p

input type="submit" name="button" id="button" value="查询" /

/p

/form

/body

/html

然后我给你一个test.php的文件代码:

?php

$name    =    trim($_POST['name']);

$vipid    =    trim($_POST['vipid']);

$con = mysql_connect("127.0.0.1","数据库用户名","数据库密码");

if (!$con)

{

die('Could not connect: ' . mysql_error());

}

$a    =    mysql_select_db("数据库名字", $con);

$sql    =    "select * from kh_customer where name = '$name' and vipid = '$vipid'";

$result = mysql_query($sql);

while($row = mysql_fetch_array($result))

{

echo $row['name'] . " " . $row['data'];

echo "br /";

}

mysql_close($con);

?

页面美化自己去搞!只能帮你这么多了


本文标题:php提取数据库并显示 php获取数据
转载注明:http://myzitong.com/article/dooiejd.html