我喜歡在輸入字段中填充標準值。
我有這樣的代碼:
PHP表單輸入值不起作用
$stma = $conn->prepare("SELECT * FROM `users` WHERE ID = '".$_GET['gebruiker']."' ");
$stma->execute();
$row_count = $stma->rowCount(); // returns 1
foreach ($conn->query($stma) as $rows) {
$Username = $rows['Username'];
}
/// my form
echo '<form method="POST" >
<table>
<th colspan="3"><h1>Gebruiker bewerken</h1></th>
<tr>
<th>
<h3>Gebruikersnaam: </h3>
</th>
<td>
<input style="width: 70%;" type="text" READONLY value="'.$Username.'" >
// the value must be filled in this input field
</td>
</tr>
<tr>
<th>
<h3>Wachtwoord: </h3>
</th>
<td>
<input style="width: 70%;" type="password" name="wachtwoord" REQUIRED>
</td>
</tr>
<tr>
<th>
</th>
<td colspan="2">
<input type="submit" name="bewerken" class="button" style="vertical-align:middle" value="Opslaan">
</td>
</tr>
'.$error.'
</table>
</form>';
代碼不會在我從數據庫中得到了價值填補。
我仍然得到一個空的表單字段。
我的查詢返回1個結果行(我查過)
有人看到我的錯誤嗎?
我不認爲我做了錯誤(它必須有我我的錯,它爲我工作的其他形式太)
在你的foreach()裏放一個** print_r($ rows)**並檢查它包含了什麼? –
@MayankPandeyz它沒有顯示任何東西,當我添加print_r(行) –
這就是你在輸入文本兄弟沒有得到任何東西的原因 –