我已经提到过这篇文章How to get row ID in button click?,但仍然无法使其加载值,我不知道为什么。我很确定id已经在profile.php中被正确捕获。以下是我的代码:
hanj.php
style type="text/css">
.buttonize {
text-decoration: none;
border: 1px solid #ccc;
background-color: #efefef;
padding: 10px 15px;
-moz-border-radius: 11px;
-webkit-border-radius: 11px;
border-radius: 11px;
text-shadow: 0 1px 0 #FFFFFF;
}
<?php require_once('Connections/conn.php');?>
</style>
<table border="1" cellpadding="5" cellspacing="2" width="600">
<tr>
<th>Vendor Id</th>
<th>Kategori</th>
<th>Nama Vendor</th>
<th>Alamat</th>
<th>Poskod</th>
<th>Bandar</th>
<th>Negeri</th>
<th>No</th>
<th>Email</th>
</tr>
<?php
session_start();
$_SESSION['profile']= $row ['v_id'];
mysql_select_db ($database_conn,$conn);
$query="SELECT v_id,type,companyName,address,code,city,state,contact,email FROM vendor";
$result=mysql_query($query) or die(mysql_error());
while($row=mysql_fetch_array($result))
{
echo "</td><td>";
echo $row['v_id'];
echo "</td><td>";
echo $row['type'];
echo "</td><td>";
echo $row['companyName'];
echo "</td><td>";
echo $row['address'];
echo "</td><td>";
echo $row['code'];
echo "</td><td>";
echo $row['city'];
echo "</td><td>";
echo $row['state'];
echo "</td><td>";
echo $row['contact'];
echo "</td><td>";
echo $row['email'];
echo "</td><td>";
print '<center><a href="profile.php?id='.$row['v_id'].'" class="buttonize">View</a></center>';
echo "</td></tr>";
}
?>
profile.php
<?php require_once('Connections/conn.php'); ?>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Casado</title>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<script type="text/javascript" src="http://netdna.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<link href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.3.0/css/font-awesome.min.css" rel="stylesheet" type="text/css">
<link href="http://pingendo.github.io/pingendo-bootstrap/themes/default/bootstrap.css" rel="stylesheet" type="text/css">
<div class="container">
<div class="col-md-12">
<div class="col-md-2"></div>
<div class="col-md-8">
<table class="table table-bordered">
<thead>
<tr>
<th>Pakej</th>
<th>Image</th>
<th>Harga</th>
<th>Vendor Id</th>
</tr>
</thead>
<tbody>
<?php
session_start();
mysql_select_db ($database_conn,$conn);
$vid = $_SESSION['profile'];
$sql = mysql_query("SELECT * from item where v_id = '$vid' ") or die (mysql_error());
while($res = mysql_fetch_array($sql)) {
?>
<tr>
<td><?php echo $res['pakej'] ?></td>
<td><?php echo '<img src="data:image;base64,'.$res['image'].'" class="img-thumbnail">' ?></td>
<td><?php echo $res['harga'] ?></td>
<td><?php echo $res['v_id'] ?></td>
</tr>
<?php }
?>
</tbody>
</table>
</div>
<div class="col-md-2"></div>
</div>
</div>
</body>
</html>
btw没有语法错误
答案 0 :(得分:0)
在profile.php中使用$ _GET来引用传入的'id'。即 替换以下行
$vid = $_SESSION['profile'];
这个。
$vid = $_GET['id'];
希望这有帮助。
答案 1 :(得分:0)
这个问题由Bikash Paul回答,他建议将$ _SESSION [&#39;个人资料&#39;]更改为$ _REQUEST [&#39; id&#39;]
答案 2 :(得分:0)
而不是$vid = $_SESSION['profile'];
尝试$vid = $_GET['profile'];
,如果不起作用,则print_r($ _ GET)或print_r($ _ REQUEST)&amp;向我们展示详细信息
答案 3 :(得分:0)
而不是$_SESSION['profile']
在您的$_REQUEST['id']
中使用profile.php
而应该有效。