I try to use SELECT in echo because I make while loop and I want to SELECT id in table account so I will use this data inside form
here is some of my php code:
$sql = "SELECT * FROM account";
$getquery = mysqli_query($conn, $sql);
while ($runrows = mysqli_fetch_array($getquery)) {
echo '
<!-- td -->
<li class="account">
<div class="products">
' . $runrows["id"] . '
</div>
<span class="status">
<span></span>
' . $runrows["username"] . '</span>
<div class="button-wrapper">
' . $runrows["rank"] . '
</div>
<div class="button-wrapper" style="margin-right: 10px;">
<a href="#edit' . $runrows["id"] . '"><button style="margin-right: 10px; background-color: #4299e1; border: none; border-radius: 5px; font-size: 25px; font-family: supermarket; border: black solid 1px;">edit</button></a>
<a href="#delete"><button style="margin-right: 10px; background-color: #f56565; border: none; border-radius: 5px; font-size: 25px; font-family: supermarket; border: black solid 1px;">delete</button></a>
</div>
</li>
<div id="edit' . $runrows["id"] . '" class="overlay" style="font-family: supermarket">
<div class="popup">
<h2 style="font-family: supermarket"><i class="fa-solid fa-user-pen"></i> edit data of user ID : ' . $runrows["id"] .'</h2>
<a class="close" href="/backend/user/"><i class="fa-solid fa-xmark"></i></a>
<div class="content" style="overflow: hidden; font-size: 20px;">
<form action="collector.php" method="post">
<?php
$sql = "SELECT * FROM account WHERE id = ' . $runrows["id"] . '";
$queryId = mysqli_query($conn,$sql);
$idRows = mysqli_fetch_array($queryId)
?>
<div class="txt_field">
<input type="text" required name="phone" max-length="10" style="color: var(--content-color); font-family: supermarket;" value="' . $idRows["id"] .'">
<span></span>
<label style="font-family: supermarket;">' . $runrows["id"] . '</label>
</div>
</form>
</div>
</div>
</div>';
as you can see I try to use SELECT in echo but at input feild it don’t show me nothing (all of php syntax are correct but I don’t sure if it correct or not in echo that have sql inside)
here is some of my database
id | username | password |
---|---|---|
1 | test1 | testno1 |
2 | test2 | testno2 |
If anyone have better way or can fix my code please let me know. Thanks
2
Answers
I think it should something like this in your php file (replace html tags with yours, but the logic should be like this):
Have you tried error_reporting for find errors in php code? Have you checked the DB?
Try