<?php
require_once 'config.php';
session_start();
$result = mysqli_query($link, "SELECT * FROM images where allowance=0 order by id desc");
while ($row = mysqli_fetch_array($result)) {
?>
<div id='img_div'>
<p><?php echo $row['image_text']; ?></p>
<img src="images/<?php echo $row['image']; ?>" >
<br><br>
<a role="button" class="btn btn-outline-success app" name="publish" href='admin.php?publish=true'>Publish</a>
<a role="button" class="btn btn-outline-danger app" name="reject" href='admin.php?reject=true'>Reject</a>
</div>
<?php
}
?>
<?php
if (isset($_GET['publish'])) {
$test=$_GET['id'];
$sql1 = "UPDATE images SET allowance='1' where id=$test";
if (mysqli_query($link, $sql1)) {
echo "Record updated successfully";
} else {
echo "Error updating record: " . mysqli_error($link);
}
}
?>
我在这里要做的是我是管理员。 当用户上传照片时,它将具有允许值为&#39; 0&#39;。
click here to see my mysql table with allowance value as 0
它不会在时间轴上显示。 我将通过管理员登录。因此,当我单击发布时,允许值更新为1,因此它将在时间轴中显示。
这里的问题是,当我使用此代码时,所有图像都会更新为值1.
click here to see my mysql table with allowance value as 0
我找不到mysql命令的特定WHERE条件来更新我的允许值..
还是有人为这个概念有任何代码.. 即,用户上传照片,它将存储在数据库中,然后在管理员批准后,它将在时间轴中显示...
提前致谢...
答案 0 :(得分:0)
<?php
require_once 'config.php';
session_start();
if (isset($_GET['publish'])) {
$test=$_GET['id'];
$sql1 = "UPDATE images SET allowance='1' where id=$test";
if (mysqli_query($link, $sql1)) {
echo "Record updated successfully";
} else {
echo "Error updating record: " . mysqli_error($link);
}
}
$result = mysqli_query($link, "SELECT * FROM images where allowance=0 order by id desc");
while ($row = mysqli_fetch_array($result)) { ?>
<div id='img_div'>
<p><?php echo $row['image_text']; ?></p>
<img src="images/<?php echo $row['image']; ?>" >
<br><br>
<a role="button" class="btn btn-outline-success app" name="publish" href='admin.php?publish=true&id=<?php echo $row['id']; ?>'>Publish</a>
<a role="button" class="btn btn-outline-danger app" name="reject" href='admin.php?reject=true'>Reject</a>
</div>
<?php } ?>