我在使用分页显示表格中的mysql数据时遇到问题。使用bootstrap框架。希望有人能帮助我解决这个问题。
我正在使用MAMP,在mysql中,我创建了2个以下名称的数据库:
在htdocs中使用以下名称创建2个不同的文件夹:
在第一天,我将所有文件放在同一个文件夹中,但是我收到了错误 - 没有选择数据库。检查mysql,权限已经默认为全局。结果如下图所示:
http://i58.tinypic.com/rll6jc.png
然后,当我使用不同的文件夹时,我得到“没有选择数据库”
使用数据填充两个数据库中的表。 不确定为什么数据没有显示在index.php ..
谢谢磨坊!!〜
<?php
include('Inventory/includes/config.php');
$per_page = 5;
$adjacents = 5;
$pages_query = mysql_query("SELECT COUNT(id), item, brand, model, qty FROM invdata") or die(mysql_error());
//get total number of pages to be shown from total result
$pages = ceil(mysql_result($pages_query, 0) / $per_page);
//get current page from URL ,if not present set it to 1
$page = (isset($_GET['page'])) ? (int)$_GET['page'] : 1 ;
//calculate actual start page with respect to Mysql
$start = ($page - 1) * $per_page;
//execute a mysql query to retrieve all result from current page by using LIMIT keyword in mysql
//if query fails stop further execution and show mysql error
$query = mysql_query("SELECT id, item, brand, model, qty FROM invdata LIMIT $start, $per_page") or die(mysql_error());
$pagination="Pagination";
//if current page is first show first only else reduce 1 by current page
$Prev_Page = ($page==1)?1:$page - 1;
//if current page is last show last only else add 1 to current page
$Next_Page = ($page>=$pages)?$page:$page + 1;
//if we are not on first page show first link
if($page!=1) $pagination.= '<a href="?page=1">First</a>';
//if we are not on first page show previous link
if($page!=1) $pagination.='<a href="?page='.$Prev_Page.'">Previous</a>';
//we are going to display 5 links on pagination bar
$numberoflinks=5;
//find the number of links to show on right of current page
$upage=ceil(($page)/$numberoflinks)*$numberoflinks;
//find the number of links to show on left of current page
$lpage=floor(($page)/$numberoflinks)*$numberoflinks;
//if number of links on left of current page are zero we start from 1
$lpage=($lpage==0)?1:$lpage;
//find the number of links to show on right of current page and make sure it must be less than total number of pages
$upage=($lpage==$upage)?$upage+$numberoflinks:$upage;
if($upage>$pages)$upage=($pages-1);
//start building links from left to right of current page
for($x=$lpage; $x<=$upage; $x++){
//if current building link is current page we don't show link,we show as text else we show as linkn
$pagination.=($x == $page) ? ' <strong>'.$x.'</strong>' : ' <a href="?page='.$x.'">'.$x.'</a>' ;
}
//we show next link and last link if user doesn't on last page
if($page!=$pages) $pagination.= ' <a href="?page='.$Next_Page.'">Next</a>';
if($page!=$pages) $pagination.= ' <a href="?page='.$pages.'">Last</a>';
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Test 2</title>
<link href="Inventory/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div class="container-fluid">
<div class="table-responsive">
<table class="table">
<tr>
<th>ITEM</th>
<th>BRAND</th>
<th>MODEL</th>
<th>QUANTITY</th>
</tr>
<?php
while($row = mysql_fetch_array($query))
{
$f1 = $row['item'];
$f1 = $row['brand'];
$f1 = $row['model'];
$f1 = $row['qty'];
?>
<tr>
<td><?php echo $f1 ?></td>
<td><?php echo $f2 ?></td>
<td><?php echo $f3 ?></td>
<td><?php echo $f4 ?></td>
</tr>
<?php
} //while
?>
</table>
</div>
</div>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="Inventory/js/bootstrap.min.js"></script>
</body>
</html>
<?php
$mysql_hostname = "localhost";
$mysql_user = "root";
$mysql_password = "";
$mysql_database = "data";
$bd = mysql_connect($mysql_hostname, $mysql_user, $mysql_password, or die ("Connection error");
mysql_select_db($mysql_database, $bd) or die ("Database error");
?>
答案 0 :(得分:0)
更改此行
$bd = mysql_connect($mysql_hostname, $mysql_user, $mysql_password) or die ("Connection error");
到
mysqli_*
我建议您使用mysql_*
代替mysql_*
,因为public aspect TestAspect {
pointcut publicMethodExecuted(): execution(public !static * *(..));
int around() : publicMethodExecuted() {
//I need parameters values here
//to write their to log
int original_return_value = proceed();
return original_return_value * 100;
}
}
现已弃用。
我希望这会对你有所帮助。