[英]How do I update the value attribute of a form input with data from variable?
如何使用變量中的數據更新表單輸入的值屬性?
現在,當表單顯示時,它不會從變量 istead 中獲取數據,它只是自動填充:{$title}
我嘗試了花括號和不同的引號來解決這個問題。 我忽略了一些事情。
for ($i = 0; $i < sizeof($list_array); $i++) {
$title = $list_array[$i]->find('h3', 0)->plaintext;
$price = $list_array[$i]->find('span[class="hz-Listing-price hz-text-price-label"]', 0);
$string = $price;
$clean_string = preg_replace('/[^\d]+/', '', $string);
$integer = intval($clean_string);
$result = $integer / 100;
echo "<li>";
if ($result < 10000 && $result > 2000) {
echo "<p><span style=\"color: green\">$title</span></p>";
echo "<p><span style=\"color: green\">$result</span></p>";
echo
'<div class="container">
<div class="row">
<div class="col-md-12">
<div class="card">
<div class="card-header">
<h4>
Add Contacts
<a href ="index.php" class=" btn btn-danger float-end" > Back</a>
</h4>
</div>
<div class="card-body">
<form action="code.php" method="POST">
<div class="form-group mb-3">
<label for="">First Name</label>
<input name="first_name" <sup>value="{$title}"</sup> class="form-control">
</div>
<div class="form-group mb-3">
<label for="">Phone Number</label>
<input name="phone" value="$result" class="form-control">
</div>
<div class="form-group mb-3">
<label for="">Note</label>
<input type="text" name="note" class="form-control">
<div class="form-group mb-3">
<button type="submit" name="save_contact" class="btn btn-primary">Save contact</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>';
} else {
//echo "<p>$title</p>";
//echo "<p>$result</p>";
}
}
我需要闖入回聲。
我這樣做了
輸入類型=“文本”名稱=“名字”值='。 $標題。 類=“表單控制”>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.