i will make this clear. So I just want to display all my data in my text boxes when I select an option or value in my Select Dropdown but I have no clue how to do it. it seems like there's nothing being display after I select a value on select dropdown thanks!
here is what my database looks like
also i am passing the amount on the selectbox so when i click for example 500 then the textboxes will be filled with its value like pin
, code
and other fields inside the table
here is what my page looks like
<form action="" method="POST">
<div class="row col-md-4">
<?php
$connection = mysqli_connect("localhost","root","");
$db = mysqli_select_db($connection, 'qrproject');
?>
<label>Amount</label>
<select class="form-control validate" name="id">
<?php
$sql = mysqli_query($connection, "SELECT amount FROM scratch_cards GROUP BY `amount`");
while ($row = $sql->fetch_assoc()){
echo "<option value=\"amnt1\">" . $row['amount'] . "</option>";
}
?>
</select>
<br>
<input type="submit" class="form-control btn-warning" name="search" value="Search Data"></input><br>
<?php
if(isset($_POST['search']))
{
$id = $_POST['id'];
$query = "SELECT * FROM scratch_cards WHERE amount='$id' ORDER BY RAND() LIMIT 1";
$query_run = mysqli_query($connection, $query);
if($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="txtstatus" 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">
<input type="hidden" name="success" class="validate form-control" id="success" value="SUCCESS">
</form>
<?php
}
}
?>
</form>
No matter what is clicked. value=\\"amnt1\\"
will be passing amnt1
with the submitted data.
You should remove that attribute and just use the text value.
You would have discovered this issue yourself, if you would have simply echoed out $id
. Basic diagnostics should be done before posting a question.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.