我的当前页面displayitems.php
。我有一个风格和按钮的背景图像和隐藏的输入类型=按钮type='hidden'
“隐藏”。
点击后,我可以检索图像的ID。每当我按一下按钮(含图片)它显示的按钮的准确图像中的另一页是userdetails.php
,我得到一个返回按钮,将重定向到displayitems.php。
现在,这里我的问题是,如果我点击另一个按钮(图像),它可以在任何的删除以往的图像显示在过去的形象,而不是一个新的,我点击后显示当前按钮
这是我的主页
<?php
require 'header.php';
?>
<main>
<?php
require 'uploaditems.php';
echo "<br>";
require 'loginlogout.php';
echo "<div>";
require 'displayitems.php';
echo "</div>";
?>
</main>
我displayitems.php
<?php
if(isset($_SESSION['userId'])){
require "includes/dbh.php";
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Page Title</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="style.css" type="text/css" media="screen" href="style.php"/>
<script src="main.js"></script>
<style>
.product{
border:1px solid
margin:-1px 19px 3px -1px;
padding: 10px;
text-align:center;
bacgkround-color:#efefef;
}
</style>
</head>
<body>
<?php
include_once 'includes/dbh.php';
$sql="SELECT * FROM gallery ORDER BY orderitems DESC;";
$stmt=mysqli_stmt_init($conn);
if(!mysqli_stmt_prepare($stmt,$sql)){
echo "sql statement failed in displayitems.php";
}else{
mysqli_stmt_execute($stmt);
$result=mysqli_stmt_get_result($stmt);
if(mysqli_num_rows($result)>0){
while($row=mysqli_fetch_assoc($result)){
?>
<div class="col-md-3">
<form method="POST" action="userdetails.php">
<input type="hidden" name="hiddenId" value=<?php echo $row['idGallery'];?>>
<div class="product" style="float: left;">
<button type="hidden" name='displaydetails'
style='background-
image:url(images/<?php echo $row['imgFullNameGallery'];?>
);width:150px; height:200px; margin:auto; background-size:100% 100%; b
ackground-repeat:no-repeat;>
</button>
</form>';
<br>
<br><br><h3><?php echo $row['nameitem']?></h3>
<h3><?php echo $row['price']?></h3>
<br>
</div>
</div>
<?php
}
}
}
}
?>
</body>
</html>
我userdetails.php
<?php
session_start();
if(isset($_POST['displaydetails'])){
if(isset($_SESSION['userId'])){
这是我得到了图像的隐藏标识
$idofimg=$_POST['hiddenId'];
require 'includes/dbh.php';
我已经创建了一个查询,我想隐藏标识的所有数据
$sql="SELECT * FROM gallery WHERE idGallery=? ;";
$stmt=mysqli_stmt_init($conn);
if(!mysqli_stmt_prepare($stmt,$sql)){
echo "sql statement failed in displayitems.php";
}else{
mysqli_stmt_bind_param($stmt,'i',$idofimg);
mysqli_stmt_execute($stmt);
$result=mysqli_stmt_get_result($stmt);
if(mysqli_num_rows($result)>0){
while($row=mysqli_fetch_assoc($result)){
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Page Title</title>
<meta name="viewport" content="width=device-width, initial-
scale=1">
<link rel="stylesheet" type="text/css" media="screen"
href="main.css" />
<script src="main.js"></script>
</head>
<body>
<img src="images/<?php echo $row['imgFullNameGallery'];?>" style
=width:330px; height:300px; margin:auto; background-size:100% 100%;
background-repeat:no-repeat;>
<div>
<h3>Details</h3>
<table>
<tr>
<td>Condition:</td>
<td>ha</td>
</tr>
</div>
这就是我想要点击的另一个图像按钮会显示当前图像不是过去图像时把我的情况,我会删除所有这些当前的数据并回到index2.php然后
<form action='index2.php' method='POST'>
<button type='submit'>BACK</button>
<?php
$count=1;
?>
</form>
<?php
}
}
}
} else{
echo "fail";
}}
?>
</body>
</html>
在这里我displayitems.php我输入类型=“隐藏”名称=“hiddenId”值=>只得到1倍的值时,按钮类型=“隐藏”的名字=“displaydetails”>点击后没有得到任何价值。所以,当我去userdetails.php仅显示由于输入型1点的细节。所以我应该删除输入型displayitems.php,只是给该按钮的值,所以每当有人点击它会产生一个新的ID,也显示出新的细节。
只是改变这displayitems.php
<input type="hidden" name="hiddenId" value=<?php echo $row['idGallery'];?>>
<div class="product" style="float: left;">
<button type="hidden" name='displaydetails'
style='background-
image:url(images/<?php echo $row['imgFullNameGallery'];?>
);width:150px; height:200px; margin:auto; background-size:100% 100%; b
ackground-repeat:no-repeat;>
</button>
这
<div class="product" style="float: left;">
<button type="hidden" name='displaydetails' value=<?php echo
$row['idGallery'];?>
style='background-
image:url(images/<?php echo $row['imgFullNameGallery'];?>
);width:150px; height:200px; margin:auto; background-size:100% 100%; b
ackground-repeat:no-repeat;>
</button>
并userdetails.php
if(isset($_POST['displaydetails'])){
if(isset($_SESSION['userId'])){
$idofimg=$_POST['hiddenId'];
这
if(isset($_POST['displaydetails'])){
if(isset($_SESSION['userId'])){
$idofimg=$_POST['displaydetails'];