您看到的是我将图像显示为搜索结果的代码。我在下面有一个 anchor ,所以当您单击图片时,它会将您带到测试页面。
我想设置一个页面来显示与该图片关联的其余行条目:
(Picture) Player: Steve Sax
Card Type: Donruss
Year: 1989
Value: $2.00
如何获取搜索结果行中的“id”,然后将其回显到显示在 TEST 页面上的表格中?
<?php
$servername = "*********";
$username = "*********";
$password = "*********";
$dbname = "*********";
$username1=$_SESSION['activeusername'];
$userid = $_SESSION['activeid'];
$userid = $_SESSION['activeid'];
$itemid = $_SESSION['activeid'];
// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$sql = "SELECT * FROM useritems JOIN (users, iteminfo) on (users.id=useritems.UserID AND iteminfo.ID=useritems.ItemID) AND userid='2'";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) {
// output data of each row
while($row = mysqli_fetch_assoc($result)) {
echo "<a href='test1.php'><div id='frame'>
<div id='splash-image' style='background: url(".$row['imagename']."); background-size:cover;'></div>
<div id='text'>
<table >
<tr></tr>
</table>
</div>
</div>";
}
} else {
echo "You Have No Items In Your Closet!!!";
}
mysqli_close($conn);
?>
最佳答案
通过 get 传递 id 为:
echo "<a href='test1.php?id=". $row['id']."'>
并将其放在着陆页上:
$id=$_GET['id'];
echo $id;
关于php - 如何抓取搜索结果的id来自,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32235070/