我已经搜索了许多类似的问题,但没有找到任何有效的方法。
我正在尝试编写一个简单的php crud页面,其中 我有一个使用nav-tabs的index.php页面(下拉菜单,因为我将在使这些页面正常工作后添加更多页面)
我有一个下拉菜单,链接到vendorlanding.php页面 显示网格和简单的添加/更新/删除链接。
我可以从index.php成功导航到此页面,但是当我单击vendorlanding.php中的任何链接(即添加新的供应商:addvendor.php)时,没有任何反应。
我希望它在当前标签中打开addvendor.php页面。
非常感谢您的帮助
下面是index.php和vendorlanding.php的内容
index.php:
<?php
// Initialize the session
session_start();
// If session variable is not set it will redirect to login page
if(!isset($_SESSION['username']) || empty($_SESSION['username'])){
header("location: login.php");
exit;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Test Ledger</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#myTab a").click(function(e){
e.preventDefault();
$(this).tab('show');
});
});
</script>
<style type="text/css">
.bs-example
{
width: 55%;
padding-left: 15%;
}
.header
{
width: 55%;
padding-left: 15%;
}
.footer
{
width: 55%;
padding-left: 15%;
}
.padding2
{
margin: 100px;
padding-left: 50%;
margin: 100px;
}
body{ font: 14px sans-serif; }
</style>
</head>
<body>
<div class = "header">
<h2>welcome <b><?php echo htmlspecialchars($_SESSION['username']); ?></b>. <a href="logout.php" class="btn btn-danger btn-sm">Sign Out</a>
</br>
</br>
</div>
</br>
</br>
<div class="bs-example">
<ul class="nav nav-tabs" id="myTab">
<li class="active"><a data-toggle="tab" href="#Home">Home</a></li>
<li class="dropdown">
<a data-toggle="dropdown" class="dropdown-toggle" href="#">Ledger Content<b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a data-toggle="tab" href="#viewvendors">View Vendors</a></li>
</ul>
</li>
<li class="dropdown">
<a data-toggle="dropdown" class="dropdown-toggle" href="#">Manage Users<b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a data-toggle="tab" href="#adduser">Add User</a></li>
</ul>
</li>
</ul>
<div class="tab-content">
<div id="Home" class="tab-pane fade in active">
<?php
include("main.inc.php");
?>
</div>
<div id="viewvendorslanding" class="tab-pane fade">
<?php
include("vendorLanding.php");
?>
</div>
<div id="adduser" class="tab-pane fade">
<?php
include("register.php");
?>
</div>
<div id="addvendor" class="tab-pane fade">
<?php
include("addVendor.php");
?>
</div>
</div>
</div>
</br>
</br>
</br>
<div class="footer">
<?php
include("footer.inc.php");
?>
</div>
</body>
</html>
vendorlanding.php->此按钮具有添加新供应商的按钮(无效)
<body>
<div class="wrapper1">
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<div class="page-header clearfix">
<h2 class="pull-left">Vendor Details</h2>
<a href="index.php#addvendor" class="btn btn-success pull-right">Add New Vendor</a>
</div>
<?php
// Include config file
require_once '../dbConfig.php';
// Attempt select query execution
$sql = "SELECT * FROM vendors";
if($result = mysqli_query($link, $sql)){
if(mysqli_num_rows($result) > 0){
echo "<table class='table table-bordered table-striped'>";
echo "<thead>";
echo "<tr>";
echo "<th>#</th>";
echo "<th>Name</th>";
echo "<th>Description</th>";
echo "</tr>";
echo "</thead>";
echo "<tbody>";
while($row = mysqli_fetch_array($result)){
echo "<tr>";
echo "<td>" . $row['vendor_id'] . "</td>";
echo "<td>" . $row['vendor_name'] . "</td>";
echo "<td>" . $row['vendor_description'] . "</td>";
echo "<td>";
echo "<a href='vendorRead.php?id=". $row['id'] ."' title='View Record' data-toggle='tooltip'><span class='glyphicon glyphicon-eye-open'></span></a>";
echo "<a href='vendorUpdate.php?id=". $row['id'] ."' title='Update Record' data-toggle='tooltip'><span class='glyphicon glyphicon-pencil'></span></a>";
echo "<a href='vendorDelete.php?id=". $row['id'] ."' title='Delete Record' data-toggle='tooltip'><span class='glyphicon glyphicon-trash'></span></a>";
echo "</td>";
echo "</tr>";
}
echo "</tbody>";
echo "</table>";
// Free result set
mysqli_free_result($result);
} else{
echo "<p class='lead'><em>No records were found.</em></p>";
}
} else{
echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
}
// Close connection
//mysqli_close($link);
?>
</div>
</div>
</div>
</div>
</body>
</html>