如何在Php中使用Oops从数据库中获取所有数据 [英] How Can I Fetch All The Data From Database Using Oops In Php
本文介绍了如何在Php中使用Oops从数据库中获取所有数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<?php
include('../includes/connection.php');
class User
{
public $result = array();
public function __construct(){
$db = new DB_con();
}
##############pagelisting########################
public function fetchpages()
{
$query = mysql_query("select * from admin_cms_page order by id");
$result = array();
while ($record = mysql_fetch_array($query)) {
echo $result[] = $record;
}
return $result;
}
}
?>
HTML code:
HTML code:
<div class="box-body table-responsive">
<table id="example2" class="table table-bordered table-hover">
<thead>
<tr>
<th>Sl no.</th>
<th>Page Name</th>
<th>Page Title</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php <br mode="hold" /?> $page = $obg->fetchpages('admin_cms_page');?>
<tr>
<td><?php echo $i;??></td>
<td><?php echo $page['pagename'];??></td>
<td><?php echo $page['pagetitle'];??></td>
<td><a class="btn btn-primary" href="manage-page.php?id=<?php echo $page['id']; ?>">Edit </a>
<!-- <a class="btn btn-danger" href="manage-page.php?delete=<?php echo $page['id']; ?>" > Delete </a>-->
</td>
</tr>
</tbody>
</table>
</div>
推荐答案
result = array();
public function __construct(){
result = array(); public function __construct(){
db = new DB_con();
}
############# pagelisting ################## ######
公共函数fetchpages()
{
db = new DB_con(); } ##############pagelisting######################## public function fetchpages() {
query = mysql_query( select * from admin_cms_page order by id);
query = mysql_query("select * from admin_cms_page order by id");
这篇关于如何在Php中使用Oops从数据库中获取所有数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文