a.php提取数据库数据怎么用b.htm显示出来?
a.php<?require_once("class_mysqlConn.php");classUserInfo{protected$userName;//属性,用户名p...
a.php
<?
require_once("class_mysqlConn.php");
class UserInfo{
protected $userName; //属性,用户名
protected $userPhone ; //属性,手机
protected $userZone ; //属性,小区
protected $userSqure ; //属性,面积
protected $userQQ ; //属性,QQ
protected $userPrince ; //属性,预算
protected $userInfo; //存储数据库返回信息的数组变量.
protected $mysqlConn;
public function __construct($name){
$this->mysqlConn = new MysqlConn();
$sql = "select * from zhuangxiu order by 时间 DESC"; //查询的sql
$rs = $this->mysqlConn->query($sql);
$this->userInfo = $this->mysqlConn->next();
$this->getInfo(); //调用传递信息的方法.
}
// 获取信息传递给属性的方法
protected function getInfo(){
$this->userTime = $this->userInfo["时间"];
$this->userName = $this->userInfo["姓名"];
$this->userZone = $this->userInfo["小区"];
$this->userSqure = $this->userInfo["面积"];
$this->userPrince = $this->userInfo["预算"];
}
//返回每个属性的public 方法.
public function getUserTime(){
return $this->userTime;
}
public function getUserName(){
return $this->userName;
}
protected function getUserZone(){
return $this->userZone;
}
public function getUserSqure(){
return $this->userSqure;
}
public function getUserPrince(){
return $this->userPrince;
}
}
?> 展开
<?
require_once("class_mysqlConn.php");
class UserInfo{
protected $userName; //属性,用户名
protected $userPhone ; //属性,手机
protected $userZone ; //属性,小区
protected $userSqure ; //属性,面积
protected $userQQ ; //属性,QQ
protected $userPrince ; //属性,预算
protected $userInfo; //存储数据库返回信息的数组变量.
protected $mysqlConn;
public function __construct($name){
$this->mysqlConn = new MysqlConn();
$sql = "select * from zhuangxiu order by 时间 DESC"; //查询的sql
$rs = $this->mysqlConn->query($sql);
$this->userInfo = $this->mysqlConn->next();
$this->getInfo(); //调用传递信息的方法.
}
// 获取信息传递给属性的方法
protected function getInfo(){
$this->userTime = $this->userInfo["时间"];
$this->userName = $this->userInfo["姓名"];
$this->userZone = $this->userInfo["小区"];
$this->userSqure = $this->userInfo["面积"];
$this->userPrince = $this->userInfo["预算"];
}
//返回每个属性的public 方法.
public function getUserTime(){
return $this->userTime;
}
public function getUserName(){
return $this->userName;
}
protected function getUserZone(){
return $this->userZone;
}
public function getUserSqure(){
return $this->userSqure;
}
public function getUserPrince(){
return $this->userPrince;
}
}
?> 展开
- 你的回答被采纳后将获得:
- 系统奖励15(财富值+成长值)+难题奖励10(财富值+成长值)+提问者悬赏20(财富值+成长值)
2个回答
2015-03-25
展开全部
以下示例读取数据库,并以表格显示:
<?php
header('Content-type:text/html;charset=utf-8');
$db = new mysqli('localhost','root','root','books');
$rows = $db->query('SELECT * FROM customers');
echo '<table border="1"><tr><td>姓名</td><td>年龄</td></tr>';
while($row = $rows->fetch_assoc()){
echo '<tr><td>'.$row['name'].'</td>';
echo '<td>'.$row['address'].'</td></tr>';
}
?>
<?php
header('Content-type:text/html;charset=utf-8');
$db = new mysqli('localhost','root','root','books');
$rows = $db->query('SELECT * FROM customers');
echo '<table border="1"><tr><td>姓名</td><td>年龄</td></tr>';
while($row = $rows->fetch_assoc()){
echo '<tr><td>'.$row['name'].'</td>';
echo '<td>'.$row['address'].'</td></tr>';
}
?>
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询