你好,我有一个数据库,它的数据是这请看这张图片
我需要一个解决这个问题的办法,解决办法是我需要的数据是改变,而不是重复,所以当我输入一个值,是写在数据库上的文本框上显示的值不会重复和改变每次我输入相同的值。
<form action="" method="POST">
<div class="row col-md-4">
<label>Amount</label>
<input type="text" name="id" class="form-control validate">
<br>
<input type="submit" class="form-control btn-warning" name="search" value="Search Data"></input><br>
//HERE IS WHERE I SUBMIT THE DATA RIGHT NOW IT IS NOT RANDOMIZED WHEN I SUBMIT AGAIN THE SAME VALUE APPEARS
<?php
$connection = mysqli_connect("localhost","root","");
$db = mysqli_select_db($connection, 'qrproject');
if(isset($_POST['search'])){
$id = $_POST['id'];
$query = "SELECT * FROM scratch_cards WHERE amount='$id' ";
$query_run = mysqli_query($connection, $query);
while($row = mysqli_fetch_array($query_run)) {
?>
<form action="" method="POST">
<input type="text" name="code" value="<?php echo $row['code'] ?>" class="form-control validate" id="mapo">
<input type="text" name="pin" value="<?php echo $row['pin'] ?>" class="form-control validate" id="mact">
<input type="text" name="status" value="<?php echo $row['status'] ?>" class="validate form-control" id="soluong">
<input type="date" name="card_expiration" value="<?php echo $row['card_expiration'] ?>" class="validate form-control" id="cardex">
<input type="number" name="card_validity" value="<?php echo $row['card_validity'] ?>" class="validate form-control" id="cardval">
</form>
<?php
}
}
?>
</form>
1条答案
按热度按时间cpjpxq1n1#
也许根据你的评论,你需要独特的记录,所以你可以使用
DISTINCT
在您的查询中,通过对任何列赋予distinct,您将不会得到重复的记录。在您的案例中:
也许这能帮助你获得独一无二的记录